I have a grouped (by users' lastnames) TreeTable (Webix). Here's the config:
columns:[
{ id:"lastname", template:function(obj, common){
return common.icon(obj, common)+obj.lastname
} }
],
scheme:{
$group:{
by:function(obj){
return obj.lastname.substring(0,1); // grouping by first letter
},
map:{
lastname:[function(obj){
return obj.lastname.substring(0,1);
}]
}
}
},
The snippet (the same config, another dataset)
With the map
property template
shows the first letter as the branch title. But I can't figure out how to show the count of the items in each branch. Something like
and so on. How to do this? Thanks.
you have to customize the template function of your columns such that for obj.$level==1 in the group it shows the count of elements (obj.$count) along with the title and for others it shows only the title. The required code is below :
webix.ui({
view:"treetable",
id:"treetable",
columns:[
{
id:"title", header:"Film title", width:250,
template:function(obj, common){
if(obj.$level == 1){
return common.icon(obj, common)+ obj.title + " ( " + obj.$count + " ) " ;
}
else{
return common.icon(obj, common)+ obj.title ;
}
}
}
]
/****Your Code***/
});