Available only in PRO Edition
Webix DataTable features Excel-like area selection. You can click on any cell in the DataTable and move the mouse pointer over the grid. A block of cells will be selected and colored in gray.
When you release the mouse pointer, the selection will remain and be marked with a border with a handle:
To enable area selection in DataTable, you should set the areaselect property to true:
{
view:"datatable",
id: "table",
columns:[
{ id:"rank", header:"", css:"rank", width:50},
{ id:"title", header:"Film title", width:200},
{ id:"year", header:"Released", width:80},
{ id:"votes", header:"Votes", width:120},
{ id:"rating", header:"Rating", width:80},
],
areaselect:true, data:small_film_set
}
Area selection will work only with other selection types disabled. So, the select property mustn't be set.
To refresh the selected area, you can use the refreshSelectArea method.
$$("dtable").refreshSelectArea();
Related sample: Area Selection
You can apply custom area selection in the DataTable.
Use the addSelectArea method:
$$("dtable").addSelectArea(start,end,preserve);
The parameters of the method are:
The first three parameters are mandatory, all others are optional.
You can remove a select area with the removeSelectArea method:
$$("dtable").removeSelectArea();
To remove some particular select area, you need to pass its name as a parameter of removeSelectArea(). If the name isn't passed to the method, it will remove the last unnamed select area.
To get a select area, use the getSelectArea method. The method returns the object of the select area.
var area = $$("dtable").getSelectArea();
The object of a specific select area can be received by passing the name of the area as a parameter. Without parameters, the method returns the object of the last select area.
The returned object will contain the mandatory parameters: start, end and preserve. It can also include some optional parameters: area_name, css and handle. Read more.
Several areas can be selected in the DataTable at once:
To enable multiple selection, you need to set the multiselect property to true:
{
view:"datatable",
id: "table",
columns:[
{ id:"rank", header:"", css:"rank", width:50},
{ id:"title", header:"Film title", width:200},
{ id:"year", header:"Released", width:80},
{ id:"votes", header:"Votes", width:120},
{ id:"rating", header:"Rating", width:80},
],
areaselect:true,
multiselect:true, data:small_film_set
}
If you have several select areas in the datatable, you can get all of them at once with the getAllSelectAreas method:
var areas = $$("dtable").getAllSelectAreas();
The method returns an object with configuration of all select areas in the datatable. Read more.
Related sample: Area Selection
There are several useful keyboard shortcuts that you can use for area selection.
You can read more about selection in Datatable and try your hand in Webix Tutorials.
Back to top