NEW VERSION RELEASED! Webix 11 Read More Core Updates, Extended Functionalities in SpreadSheet and File Manager and more

Paging in TreeTable, programming examples of paging in TreeTable

Paging in TreeTable, programming examples of paging in TreeTable

Get a JavaScript coding example for paging in TreeTable. Using our JS programming example, you can create pagination within the TreeTable. Feel free to use our code samples to make your own business web applications.

JS Code

var test_columns = [
  { id:"id", header:"", css:{"text-align":"right"}, width:50 },
  { id:"value", sort:"string",	header:"Title",	width:250, template:"{common.treetable()} #value#" }
];

for (var i=1; i<10; i++)
  test_columns.push({ id:"data"+i, width:100, sort:"string" });

var test_data = [];
for (var i=1; i<41; i++){
  var obj = { id:i, value:"Item at "+i }
  var data = [];
  for (var j=1; j<5; j++){
    var sub = { id:i+"."+j,  value:"Sub-item at "+j };
    for (var z = 1; z<10; z++)
      sub["data"+z]=Math.floor(Math.random()*1000);
    data.push(sub);
  }
  obj.data = data;
  test_data.push(obj);
};

var grida = {
  view:"treetable",
  id:"grida",
  leftSplit:2,
  columns: test_columns,
  width:800,
  height:600,
  yCount:10,
  pager:"pager",
  data: test_data
};

var tpl = {
  template:"<b>Paging in TreeTable</b>",
  height:40
};

var buttons = {
  cols:[
    { view:"button", width:100, value:"Open all", click:function(){$$("grida").openAll();} },
    { view:"button", width:100, value:"Close all", click:function(){$$("grida").closeAll();} }
  ]
};

var pager = {
  view:"pager",
  id:"pager",
  size:10,
  group:5,
  level:1
};

webix.ready(function(){
  webix.ui({
    padding:10, rows:[
      tpl,
      grida,
      buttons,
      pager
    ]
  });	
});