Skip to main content

Work with DataView

Setting focus on item#

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

dataview.setFocus("7");

Editing items#

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

dataview.editItem("1");

Related sample: Dataview. Edit Item

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 DataView items with the help of the Data Collection API.

Adding items into DataView#

It is possible to add more items into the initialized DataView 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

dataview.data.add({    "value": "Learning new DHTMLX" + " " + (2019 + i),    "thumbnailName": "61ot4vfL9HL.jpg",    "shortDescription": "Create your first single-page JavaScript application"},0);

Related sample: Dataview. Add

Updating DataView 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:

dataview.data.update("item_id",{    value:"Nice item"});

Related sample: Dataview. Update

Removing items from DataView#

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:

dataview.data.remove("id");

Related sample: Dataview. Delete

Filtering DataView data#

You can filter DataView data by the specified criteria with the help of the filter() method of Data collection. Check all details on parameters of the method in the Data Collection API.

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

Related sample: Dataview. Filter

Sorting DataView data#

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

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

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

Related sample: Dataview. Sort

Using Selection API#

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