To enable selection, you should include the select property into the component constructor and set its value to true (or 1).
webix.ui({
view:"dataview",
select:1, // enables the select mode
//config
});
Related sample: Selection in Dataview
The items will be selected on a mouse click.
"Ctrl"+click multiselection
webix.ui({
view:"list",
select:"multiselect",
// config
});
"Touch" multiselection
webix.ui({
view:"list",
select:"multiselect",
multiselect:"touch"
// config
});
"Ctrl"+click multiselection
webix.ui({
view:"datatable",
multiselect:true,
select:"cell", // multiple selection of cells
// config
});
"Touch" multiselection
webix.ui({
view:"datatable",
multiselect:"touch",
select:'cell',
// config
});
Moreover, components that present hierarchical data (Tree and treetable) feature the level multiselection pattern. If set, it allows multiple selection of items within one and the same tree branch, the items belonging to one and the same hierarchy level.
webix.ui({
view:"tree",
select:true,
multiselect:"level", // in addition to the enabled selection
// tree config
});
Related sample: Multiline Selection
Datatable and treetable feature more selection modes that are described in the datatable documentation.
You can select items with the help of selection methods triggered by various events;
If you don't pass any parameter into the function, all items will be selected.
You can select the first and the last items from the dataset without specifying their IDs. In this case, you should additionally apply the first() and last() methods to the component.
// selects the first data item in the list
$$("datalist").select($$("datalist").getFirstId();)
$$("dataview").select(4); // the cell containing item with ID = 4 will be selected
$$("dataview").select([2,3,4]); // the items with IDs equal to 2, 3 and 4
Keyboard navigation can be used for a component with enabled selection.
webix.ui({
view:"list",
select:true,
navigation:true
});
Related sample: Datatable: Keyboard Navigation
Note that not all data components support navigation by default. Then the KeysNavigation module should be added manually.
webix.ui({
view:"dataview",
id:"dataview1",
select:true,
navigation:true
});
webix.extend($$("dataview1"), webix.KeysNavigation);
The code above adds navigation only to this instance of a DataView, still it's possible to provide the functionality for all DataViews in the app.
For more details, refer to the Component Extending article.