Skip to main content

API iRidi. IR.ITEM_LISTBOX (List)

Methods for dynamic lists: graphical items of type List.

List​

Methods for working with a list.

IR.CreateItem()​

Create a List graphical item on the project's current page. The page can be identified using IR.CurrentPage. To create an item on a specific page, apply CreateItem() to a Page or Popup object reference obtained using IR.GetItem().

Syntax

IR.CreateItem(IR.ITEM_LISTBOX, name, X, Y, width, height);

InputValueDescription
name"Button 1"type: String
the item name, unique within the page.
X30type: Number
the X coordinate.
Y40type: Number
the Y coordinate.
width200type: Number
the item width.
height500type: Number
the item height.
Output
Object[Object ListItemPrototype]type: Object
a graphical object instance.

Example

IR.AddListener(IR.EVENT_START,0, function()
{
var src = IR.CreateItem(IR.ITEM_LISTBOX,"List 1",30,40,200,500);
IR.Log(src); // [Object ListItemPrototype]
});
Tip
  • To create a dialog item on a specific page, apply .CreateItem() to the page or popup reference:
var list_1 = IR.GetItem("Page 1").CreateItem(IR.ITEM_LISTBOX,"List 1",30,40,200,500);
IR.Log(list_1) // [Object ListItemPrototype] // create list and get the link in one action
  • The constructor lists only the basic properties required to create the item. All items also have a common set of additional properties and properties specific to their type. See Properties.

.AddItem()​

Create a list item (ListItem).

Syntax:

List.AddItem([template], [options], [customID], [position], [name]);

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object
templateList.AddItem("template", {}, cities[i])type: Object
the name of the popup used as a template
optionsitemName: "Button1", PropertyName: Value, States: [{ PropertyName: Value }]type: Object
an object containing list item settings:
* itemName - the graphical item name (String)
* PropertyName: Value - graphical item property: value
* States - an array of states, where PropertyName: Value - state property: value
customID"London"type: String
the list item identifier
position2type: Number
the position in the list
name"Template 1"type: String
the name of the popup cloned from template
Output
ListItem[Object ListItemPrototype]type: Object
the ListItem list item

Example

var cities = ["Moscow", "London", "New York"];
var List = `IR.GetItem("Page 1").GetItem("List")`;

if(List)
{
for(var i = 0; i < cities.length; i++)
{
var ListItem = List.AddItem("template", { "Name" : { Text : cities[i] }}, cities[i]);
}
}
Tip

Example project

  • When the AddItem() method is called without parameters, it adds a new list item that is an exact copy of the parent item (popup):
var List;
List = IR.GetPage("Page 1").GetItem("Item 1");
List.Template = "Popup 1";
function AddItem() {
List.AddItem();
};

.SetDataFilter()​

Add a key-value data filter.

Syntax:

List.SetDataFilter(key, value);

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object
key"city"type: String
the key
value"London"type: String
Value
Output
-

Example

// search
function search(in_key, in_value)
{

if(in_key)
{
// if value is exist then set filter
if(in_value)
List.SetDataFilter(in_key, in_value);
else

// else delete filter
List.DeleteDataFilter(in_key);

// apply filter
List.ApplyDataFilter();
}
}

.ClearDataFilter()​

Clear the data filter.

Syntax:

List.ClearDataFilter()

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
Output--
---

Example

// clear filter
List.ClearDataFilter();

.ApplyDataFilter()​

Apply the data filter.

Syntax: List.ApplyDataFilter()

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
Output--
---

Example

// apply filter
List.ApplyDataFilter();

.DeleteDataFilter()​

Delete a key from the filter.

Syntax:

List.DeleteDataFilter(key)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
key"city"String
the key.
Output--
---

Example List.DeleteDataFilter("city");

.GetItemByName()​

Get a ListItem by the popup name specified when calling AddItem.

Syntax:

List.GetItemByName(name);

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
name"Template 1"String
the name of the popup cloned from template.
Output--
ListItem[Object ListItemPrototype]type: Object
the ListItem list item.

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
var ListItem = List.GetItemByName("Template 1");
}

.GetItemByIndex()​

Get a ListItem by its index.

Syntax:

List.GetItemByIndex(index)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
index2Number
the list item index.
Output--
ListItem[Object ListItemPrototype]type: Object
the ListItem list item.

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
var ListItem = List.GetItemByIndex(10);
}

.GetItemPositionByName()​

Get the position of a ListItem by the popup name specified when calling AddItem

Syntax:

List.GetItemPositionByName(name)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
name"Template 1"String
the name of the popup cloned from template.
Output--
Position2Number
the ListItem position (number >= 0, or -1 if the item is not found).

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
var position = List.GetItemPositionByName("Template 1");
}

.GetItemPositionByCustomID()​

Get the position of a ListItem by the specified identifier.

Syntax:

List.GetItemPositionByCustomID(customId)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
customId"Moscow"String
the list item identifier.
Output--
Position2Number
the ListItem position (number >= 0, or -1 if the item is not found).

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
var position = List.GetItemPositionByCustomID("Moscow");
}

.GetSelected()​

Get the selected item or items.

Syntax:

List.GetSelected()

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
Output--
ListItem[Object ListItemPrototype]type: Object
an array of items or a single item, depending on the list's SelectMode.

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
var selected = List.GetSelected();
}

.ClearSelected()​

Clear the item selection.

Syntax:

List.ClearSelected()

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
List.ClearSelected();
}

.DeleteItemByName()​

Delete an item by the popup name specified when calling AddItem.

Syntax:

List.DeleteItemByName(name)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
name"Template 1"String
the name of the popup cloned from template.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
List.DeleteItemByName("Template 1");
}

.DeleteItemByCustomID()​

Delete an item by the specified identifier.

Syntax:

List.DeleteItemByCustomID(customId)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
customId"Moscow"String
the list item identifier.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
List.DeleteItemByCustomID("Moscow");
}

.DeleteItemByIndex()​

Delete an item by its index.

Syntax:

List.DeleteItemByIndex(index)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
index10Number
the list item index.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
List.DeleteItemByIndex(10);
}

.DeleteItemsByName()​

Delete items by the popup name specified when calling AddItem.

Syntax:

List.DeleteItemsByName(name)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
name"Template 1"String
the name of the popup cloned from template.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
List.DeleteItemsByName("Template 1");
}

.DeleteItemsByCustomID()​

Delete items by the specified identifier.

Syntax:

List.DeleteItemsByCustomID(customID)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
customId"Moscow"String
the list item identifier.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
List.DeleteItemsByCustomID("Moscow");
}

.GetItemsByName()​

Get an array of ListItem objects by the popup name specified when calling AddItem.

Syntax:

List.GetItemsByName(name)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
name"Template 1"String
the name of the popup cloned from template.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
var ListItems = List.GetItemsByName("Template 1");
}

.GetItemsByCustomID()​

Get an array of ListItem objects by the specified identifier.

Syntax:

List.GetItemsByCustomID(customID)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
customId"Moscow"String
the list item identifier.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
var ListItems = List.GetItemsByCustomID("Moscow");
}

.SelectByIndex()​

Select an item by its index.

Syntax:

List.SelectByIndex(index, bool)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
index10Number
the index.
booltrueBoolean
whether the item is selected.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
List.SelectByIndex(10, true);
}

.StartReleaseActionByIndex()​

Run the action set by ListItem.SetReleaseAction for the item at the specified index.

Syntax:

List.StartReleaseActionByIndex(index)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
index10Number
the index.
Output--
---

Example

var testFunction = function(in_listItem)
{
IR.Log(in_listItem.CustomID);
}

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
var cities = ["Moscow", "London", "New York"];
if(List)
{
for(var i = 0; i < cities.length; i++)
{
var ListItem = List.AddItem("template", {}, cities[i]);
if(ListItem)
{
ListItem.SetReleaseAction(testFunction);
}
}
}

ListItem.StartReleaseActionByIndex(1); // London
}

.ScrollByName()​

Scroll the list to the item specified when calling AddItem.

Syntax:

List.ScrollByName(name)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
name"Template 1"String
the name of the popup cloned from template.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
List.ScrollByName("Template 1");
}

.ScrollByCustomID()​

Scroll the list to the item with the specified identifier.

Syntax:

List.ScrollByCustomID(customID)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
customID"London"String
the list item identifier.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
List.ScrollByCustomID("London");
}

.ScrollByIndex()​

Scroll the list to the item at the specified index.

Syntax:

List.ScrollByIndex(index)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
index1Number
the index.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
List.ScrollByIndex(1);
}

.ScrollToStart()​

Scroll to the start of the list.

Syntax:

List.ScrollToStart()

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
List.ScrollToStart();
}

.ScrollToEnd()​

Scroll to the end of the list.

Syntax:

List.ScrollToEnd()

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
List.ScrollToEnd();
}

.SetSelectFunction()​

Set the handler function for list item selection.

Syntax:

List.SetSelectFunction(function)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
functionList.SetSelectFunction(testFunction)type: Object
the function executed when a ListItem is selected.
Output--
---

Example

var testFunction = function(in_listItem)
{
IR.Log(in_listItem.CustomID); // London
}

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
var cities = ["Moscow", "London", "New York"];
if(List)
{
for(var i = 0; i < cities.length; i++)
{
var ListItem = List.AddItem("template", {}, cities[i]);
}
}

List.SetSelectFunction(testFunction);
List.SelectByIndex(1, true); // London
}

.MoveItem()​

Change the position of a list item.

Syntax:

List.MoveItem(currentPostition, newPosition)

InputValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: Object
a reference to the list object.
currentPostition0Number
the current index.
newPosition2Number
the new index.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
List.MoveItem(0, 2); // change listItem from index 0 to index 2
}

.SetPosition()​

Scroll the list to the specified position. Obtain a List object reference using IR.GetItem().

Syntax

list.SetPosition(item);

InputValueDescription
listIR.GetItem("Page 1").GetItem("Item 1")type: Object
a reference to the list.
item0type: Number
the list item index, starting at 0.
Output
-

Example

IR.AddListener(IR.EVENT_START, 0, function()
{
var List = IR.GetItem("Page 1").GetItem("List 1");
List.SetPosition(12); // go to point
});
Tip

To scroll the list to a specified item:

  • the item must exist;
  • the list must be visible when the command runs, meaning that the page or popup containing the list must be open;
  • at least 100 ms must pass after a new list item is created; a scroll command immediately after the item creation command will not run.

.Clear()​

Delete all items from a List. Obtain a List object reference using IR.GetItem().

Syntax

list.Clear();

InputValueDescription
listIR.GetItem("Page 1").GetItem("Item 1")type: Object
a reference to the list.
Output
-

Example

IR.AddListener(IR.EVENT_START, 0, function()
{
var List = IR.GetItem("Page 1").GetItem("List 1");
List.Clear(); // clear list
});

Properties of List​

Properties of List graphical items:

IR.GetItem(page/popup).GetItem(list).property

property

Get / Put:

PropertyValueDescription
Template"Popup 1"type: string
Sets or gets the template for list items, which is one of the project's popups.
Direction0type: number
Sets or gets the list scrolling direction:
- 0 - vertical list
- 1 - horizontal list
Filter"A"type: string
Filters list items by name (or part of the name).
ScrollEnabledtruetype: boolean
Disables manual scrolling of the list in the interface. The method .SetPosition continues to work.
DragDropEnabletruetype: boolean
Enables/disables dragging list items (items change their position in the list).
Resistance50type: number
Sets or gets the list's scrolling resistance.
ScrollBartruetype: boolean
Enables/disables the scroll bar (ScrollBar).
SelectModeIR.LIST_SELECT_SINGLEtype: object
Selects or gets the selected list items:
- IR.LIST_SELECT_SINGLE - gets one item
- IR.LIST_SELECT_MULTIPLE - gets an array of items

Get:

PropertyValueDescription
ItemsCount24type: number
gets the number of items in the list.
var list = IR.GetItem("Page 1").GetItem("List 1");
//* * Template **//
IR.Log(list.Template); // "Popup 1"
list.Template = "Popup 2"; // change template if exist
//* * Direction **//
IR.Log(list.Direction); // 1
list.Direction = 0; // change direction
//* * ItemsCount **//
IR.Log(list.ItemsCount); // 24
//* * Filter **//
list.Filter = "C";
IR.Log(list.Filter); // "C"
//* * ScrollEnabled **//
list.ScrollEnabled = true; // list can be flipped manually
list.ScrollEnabled = false; // list cannot be flipped manually
//* * DragDropEnable **//
list.DragDropEnable = true; //activate dragging list items
list.DragDropEnable = false; //deactivate dragging list items
//* * Resistance **//
list.Resistance = 50; //set the scroll resistance to 50
//* * ScrollBar **//
list.ScrollBar = true; //turn on the scroll bar
list.ScrollBar = false; //turn off the scroll bar
//* * SelectMode **//
list.SelectMode = IR.LIST_SELECT_SINGLE; //getting one element
list.SelectMode = IR.LIST_SELECT_MULTIPLE. //getting an array of elements

ListItem​

Methods for working with list items (ListItem).

.SetData()​

Set custom data for a list item (this data is not used for filtering).

Syntax:

ListItem.SetData(Data)

InputValueDescription
ListItemList.GetItemByName(name)type: Object
a reference to the list item.
Data{CountryName: "Russia", CityName: "Moscow"}type: Object
custom data as an object.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
var ListItem = List.GetItemByName(name);
if(ListItem)
{
var data = {
CountryName: "Russia",
CityName: "Moscow"
}

ListItem.SetData(data);
}
}

.SetFilterKey()​

Set a key-value label for a list item so that these labels can be used for filtering.

Syntax:

ListItem.SetFilterKey(Data)

InputValueDescription
ListItemList.GetItemByName(name)type: Object
a reference to the list item.
Data{"Name": cities[i]}type: Object
custom data as an object.
Output--
---

Example

// search
function search(in_key, in_value)
{

if(in_key)
{
// if value is exist then set filter
if(in_value)
List.SetDataFilter(in_key, in_value);
else

// else delete filter
List.DeleteDataFilter(in_key);

// apply filter
List.ApplyDataFilter();
}
}

var cities = ["Moscow", "London", "New York"];
var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
for(var i = 0; i < cities.length; i++)
{
var ListItem = List.AddItem("template", {}, cities[i]);
if(ListItem)
{
ListItem.SetFilterKey({"Name": cities[i]});
}
}
}

search("Name", "Mosc");
search("Name", "Lon");

// clear filter
List.ClearDataFilter();

.SetOptions()​

Set list item settings.

Syntax:

ListItem.SetOptions(Data)

InputValueDescription
ListItemList.GetItemByName(name)type: Object
a reference to the list item.
Data// имя графического элемента
itemName:
{// свойство графического элемента: значение
PropertyName: Value,...
// массив состоянийStates:
[// свойство состояния: значение
PropertyName: Value,...]},...
type: Object
an object containing list item settings.
Output--
---

Example

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
var ListItem = List.GetItemByName(name);
if(ListItem)
{
ListItem.SetOptions({
"Item 1": {
Text: "SomeText",
Visible: false,

States: [{
Image: "Image 1"
}]
},
});
}
}

.SetReleaseAction()​

Set the function to execute on Release.

Syntax:

ListItem.SetReleaseAction(action, [space])

InputValueDescription
ListItemList.GetItemByName(name)type: Object
a reference to the list item.
actionfunction(in_listItem, in_item){IR.Log(in_listItem.Popup.Name);IR.Log(in_item.Name);IR.Log(this.city);}Object
the function executed on Release of a list item.
ListItem is the list item that was clicked.
Item is the dialog item clicked inside the list item, of the type (IR.GetItem("Item")).
[space]{city: "Moscow"}type: Object
the context ({}).
Output--
---

Example

var testFunction = function(in_listItem, in_item)
{
IR.Log(in_listItem.Popup.Name);
IR.Log(in_item.Name);
IR.Log(this.city);
}

var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
var ListItem = List.GetItemByName(name);
if(ListItem)
{
ListItem.SetReleaseAction(testFunction, {city: "Moscow"})
}
}

ListItem properties​

List item properties:

List.GetItemByName(name).property

PropertyValueDescription
ListIR.GetItem("Page 1").GetItem("List")type: object
a reference to the list object.
name"Template 1"type: string
the name of the popup cloned from template.

Get

PropertyValueDescription
Popup[Object ListItemPrototype]type: object
get the popup object representing the list item.
Parent[Object ListItemPrototype]type: object
get the List object containing the ListItem.
Data{CountryName: "Russia", CityName: "Moscow"}type: object
get custom data set using SetData().
FilterKey{"Name": cities[i]}type: object
get the list item's key-value label set using SetFilterKey().
Index1type: number
get the list item index.

Get / Put

PropertyValueDescription
Selectedtruetype: boolean
whether the item is selected:
true - the item is selected; false - the item is not selected.
Context{city: "Moscow"}type: object
the execution context for the function in SetReleaseAction().
CustomID"Moscow"type: string
the list item identifier.
Visibletruetype: boolean
list item visibility:
true - the item is visible; false - the item is not displayed in the list.
Lockedbooleantype: boolean
locking the list item at its current position (restricting DragDropEnable):
true - the item is locked; false - the item is not locked.
var List = `IR.GetItem("Page 1").GetItem("List")`;
if(List)
{
var ListItem = List.GetItemByName(name);
if(ListItem)
{
var popup = ListItem.Popup;
var list = ListItem.Parent;
var data = ListItem.Data;
var filter = ListItem.FilterKey;
var index = ListItem.Index;

var selected = ListItem.Selected;
ListItem.Selected = !selected;

var customID = ListItem.CustomID;
ListItem.CustomID = "NewCustomID";

var context = ListItem.Context;
ListItem.Context = {city: "London"};

var visible = ListItem.Visible;
ListItem.Visible = !visible;

var locked = ListItem.Locked;
ListItem.Locked = !locked;
}
}