ItemOptions class (Rollist)

ItemOptions()

new ItemOptions()

The ItemOptions type defines all the options an Item can display or own, including attributes such as value (the item's value or its HTML content), visible (indicates whether the item is shown or hidden), key (the associated key), position (the item's position), and className (an additional class applied to the item's hosting HTML element). When creating or configuring an item, these options can be used to control its properties and behavior; for example, when adding a new item using the Add() method, you can pass an object containing these fields to initialize the item. Each field in ItemOptions maps directly to a corresponding property of the Item object, making it easy to manage and access item attributes.

Every option of the ItemOptions type has associated a property of the Item object. For instance, the option:

value {string}, defines the value for individual item
is associated with the property:
Value {any}, defines the value for individual item
which means that the following statements are equivalent:
oItem.Options = {value: 100}
oItem.SetOptions({value: 100})
oItem.Value = 100
oItem.SetValue(100)
where oItem is an object of Item type

It is important to note that changing a field of the ItemOptions object does not automatically update the item. For example, oItem.Options.value = 100 does not apply the change. Instead, you must assign the Options property again, such as oItem.Options = {value: 100}, so the item updates and applies the new value.

Example
{value: "<b>caption</b>"} {object}, defines an item that shows the "caption" text in bold
{value: "caption", className: "red"} {object}, defines an item that shows the "caption" text and applies the .red style to it

Members

(static) className :string

The className field specifies an additional class name to apply to the HTML element that hosts the item. By default, the 'exrolitem' class name is applied to the HTML element that hosts the roll item. If you need to apply custom styles to specific items, you can use the className field to add an extra class name to the item's hosting element. This allows you to define CSS rules for that class and style the item accordingly. For example, if you set className to "red", the HTML element for that item will have both 'exrolitem' and 'red' as its class names, allowing you to apply styles defined in the .red CSS class to that item. The default value of the className field is null, which means that by default no extra class name is applied, and only the 'exrolitem' class is used for styling the item.

The className field is mapped to the ClassName property of the Item object, which means that the following statements are equivalent:

oItem.Options = {className: "red"}
oItem.SetOptions({className: "red"})
oItem.ClassName = "red"
oItem.SetClassName("red")
Type:
  • string
Example
null {null} or "" {string}, no extra class name applied
"red" {string}, appends 'red' to the HTML element's class name, applying the .red style to the item
className

(static) key :string

The key field specifies the key associated with an item. If no key is provided, the item's index can be used to access it. You can set the key field to a string value to easily identify and retrieve the item using that key. The Rollist.Item() method allows you to request an item either by its key or by its index. By default, the key field is null, meaning no key is assigned, and you would need to use the item's index to access it.

The key field is mapped to the Key property of the Item object, which means that the following statements are equivalent:

oItem.Options = {key: "logo"}
oItem.SetOptions({key: "logo"})
oItem.Key = "logo"
oItem.SetKey("logo")
Type:
  • string
Example
"logo" {string}, defines the item with the giving key (logo). You can use the Items.Item("logo") method to request the item giving its key.
key

(static) position :number

The position field specifies the item's position. The position field can be set to a positive number to specify the zero-based index of the item within the control, or set to null to add the item at the end of the list. The default value of the position field is null, which means that by default the item is added at the end of the list. The visible field indicates whether the item is visible or hidden.

The position field is mapped to the Position property of the Item object, which means that the following statements are equivalent:

oItem.Options = {position: 0}
oItem.SetOptions({position: 0})
oItem.Position = 0
oItem.SetPosition(0)
Type:
  • number
Example
null {null}, the null value has no effect
0 {number}, moves the item on the first position
position

(static) value :string

The value field defines the label of the item. The label can be a simple string or a complex HTML content. You can use the className field to apply CSS styles to the item, and then use HTML tags in the value field to structure the content of the item and make it more visually appealing. For instance, you can include tags such as <b> for bold text, <font color='red'> for red-colored text, and so on. By using HTML tags in the value field, you can customize the appearance of the item's label to suit your application's design and enhance the user experience.

The value field is mapped to the Value property of the Item object, which means that the following statements are equivalent:

oItem.Options = {value: "caption"}
oItem.SetOptions({value: "caption"})
oItem.Value = "caption"
oItem.SetValue("caption")
Type:
  • string
Example
"caption" {string}, defines an item that shows the "caption" text
"&lt;b&gt;caption&lt;/b&gt;" {string}, defines an item that shows the "caption" text in bold
"&lt;font color='red'&gt;caption&lt;/font&gt;" {string}, defines an item that shows the "caption" text in red color
"&lt;li&gt;caption&lt;/li&gt;" {string}, defines an item that shows the "caption" text as a list item
value

(static) visible :boolean

The visible field indicates whether the item is visible or hidden. The position field specifies the item's position. The visible field can be set to true to show the item or set to false to hide the item. The default value of the visible field is true, which means that by default the item is shown.

The visible field is mapped to the Visible property of the Item object, which means that the following statements are equivalent:

oItem.Options = {visible: false}
oItem.SetOptions({visible: false})
oItem.Visible = false
oItem.SetVisible(false)
Type:
  • boolean
Example
false {boolean}, hides the item
true {boolean}, shows the item
visible