Skip to main content

Work with List

Setting focus on item

To set focus on a List item, make use of the setFocus() method. It takes the id of an item as a parameter:

list.setFocus("7");

Related sample: List. Set active index

To get the id of a List item in focus, use the getFocus() method. It will return the id of an item in focus:

list.getFocus(); // -> "6"

Editing items

You can edit a particular List item with the help of the editItem() method. It takes as a parameter the id of an item:

list.editItem("1");

Related sample: List. Edit items

Disabling and enabling selection of an item

For information on disabling/enabling selection of an item, read Enabling/Disabling Selection object.

Using Data Collection API

You can manipulate List items with the help of the Data Collection API.

Adding items into List

It is possible to add more items into the initialized List on the fly. Use the add() method of Data Collection. It takes two parameters:

config(object) the configuration object of the added item
index(number) optional, the position to add an item at

list.data.add({value:"New item"},1);

Related sample: List. Add new item with Form

Updating List items

You can change config options of the item via the update() method of Data Collection. It takes two parameters:

idthe id of the item
configan object with new configuration of the item

For example, you can change the value of an item:

list.data.update("option_id",{
value:"Nice item"
});

Related sample: List. Editing item using Form

Removing items from List

To remove an item, make use of the remove() method of Data Collection. Pass the id of the item that should be removed to the method:

list.data.remove("option_id");

To remove all items at once, use the removeAll() method of DataCollection:

list.data.removeAll();

Related sample: List. Delete item

Filtering List data

You can filter List data by the specified criteria with the help of the filter() method of Data Collection.

Check all details on the parameters of the method in the Data Collection API.

list.data.filter({
by:"value",
match:2,
compare:(value,match,item)=>{ return parseFloat(value) % 2 == 0}
});

Related sample: List. Filtering

Filtering can be applied to any attribute of a data item.

Sorting List data

It is possible to sort data in List via the sort() method of Data Collection.

Check all details on the parameters of the method in the Data Collection API.

list.data.sort({ 
by:"value",
dir:"desc"
});

Related sample: List. Sorting

Sorting can be applied to any attribute of a data item.

Using selection API

For information on using Selection API, read Work with Selection Object.