Work with DataView
Setting focus on item
Use the setFocus() method to set focus on a DataView item. The method takes an item id as a parameter:
dataview.setFocus("7");
Editing items
You can edit a DataView item with the editItem() method. The method takes an item id as a parameter:
dataview.editItem("1");
Related sample: Dataview. Edit item using a button
Disabling and enabling selection of an item
For details on how to disable and enable selection of an item, see Enabling/Disabling Selection object.
Using Data Collection API
You can manage DataView items with the Data Collection API.
Adding items into DataView
You can add more items to an initialized DataView on the fly. Use the add() method of Data Collection. The method takes two parameters:
| config | (object) the configuration object of the new item |
| index | (number) optional, the position for the new item |
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 item using Form
Updating DataView items
You can change item settings with the update() method of Data Collection. The method takes two parameters:
| id | the id of the item |
| config | an object with the new item configuration |
For example, you can change the value of an item:
dataview.data.update("item_id",{
value:"Nice item"
});
Related sample: Dataview. Edit item with Form
Removing items from DataView
Use the remove() method of Data Collection to remove an item. Pass the item id to the method:
dataview.data.remove("id");
Related sample: Dataview. Delete item
Filtering DataView data
You can filter DataView data by specified criteria with the filter() method of Data Collection. For details on the method parameters, see 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
You can sort data in DataView with the sort() method of Data Collection.
For details on the method parameters, see the Data Collection API.
dataview.data.sort({
by:"value",
dir:"desc"
});
Related sample: Dataview. Sorting
Using Selection API
For details on the Selection API, see Work with Selection object.