In this chapter you will learn how to create index columns in DataTable.
There are 2 types of index columns:
To create a static index column in your datatable, use the following technique:
Specifying static index column in DataTable
dtable = new webix.ui({
view:"datatable",
columns:[
{ id:"index", header:"", sort:"int"},
{ id:"title", header:"Film title", sort:"string"},
{ id:"year", header:"Year", sort:"int"}
],
scheme:{
$init:function(obj){ obj.index = this.count(); }
},
...
});
Let's consider what we do in the code above:
To create a dynamic index column in your datatable, use the following technique:
Specifying dynamic index column in DataTable
dtable = new webix.ui({
view:"datatable",
id:"mytable",
columns:[
{ id:"index", header:"", sort:"int"},
{ id:"title", header:"Film title", sort:"string"},
{ id:"year", header:"Year", sort:"int"}
],
on:{
"data->onStoreUpdated":function(){
this.data.each(function(obj, i){
obj.index = i+1;
})
}
},
...
});
Let's consider what we do in the code above: