Export to PDF, Excel in TreeTable,
coding samples of export to PDF and Excel in TreeTable

JavaScript export to PDF, Excel in TreeTable

Get a JavaScript coding sample of export to PDF and Excel in TreeTable. By means of our JS coding sample you'll be able to export information from TreeTable to PDF and Excel. Feel free to use our programming samples or a snippet tool below to enhance your JavaScript skills, and make your own web applications. footer: How to make effective math calculations with Webix TreeTable widget?

JS Code

var options = { 
  flatTree:{
    id:"value",
    columns:[
      { header:"Title" },
      { header:"Section" },
      { header:"Subsection" },
    ]
  }
};

var options2 = { 
  flatTree:{
    id:"value",
    fill:true,
    columns:[
      { header:"Title" },
      { header:"Section" },
      { header:"Subsection" },
    ]
  }
};

var grida = {
  view:"treetable",
  id:"grida",
  columns:[
    { id:"id", header:"", css:{"text-align":"right"}, width:50},
    { id:"value", header:"Film title", fillspace:true,
     template:"{common.treetable()} #value#", exportAsTree:true },
    { id:"chapter",	header:"Mode", width:200}
  ],
  select:"row",
  autoheight:true,
  scroll:false,

  data:[
    { "id":"1", "value":"The Shawshank Redemption", "open":true, "data":[
      { "id":"1.1", "value":"Part 1", "chapter":"alpha"},
      { "id":"1.2", "value":"Part 2", "chapter":"beta", "open":true, "data":[
        { "id":"1.2.1", "value":"Part 1", "chapter":"beta-twin"},
        { "id":"1.2.2", "value":"Part 1", "chapter":"beta-twin"}
      ]},
      { "id":"1.3", "value":"Part 3", "chapter":"gamma" }
    ]},
    { "id":"2", "value":"The Godfather", "data":[
      { "id":"2.1", "value":"Part 1", "chapter":"alpha" },
      { "id":"2.2", "value":"Part 2", "chapter":"beta" }
    ]}
  ]
};

var buttons = {
  margin:30, cols:[
    {
      margin:10, rows:[
        { view:"button", width:110, value:"get PDF", click:function(){webix.toPDF($$("grida"));} },
        { view:"button", width:110, value:"get Excel", click:function(){webix.toExcel($$("grida"));} },
        { view:"button", width:110, value:"get CSV", click:function(){webix.toCSV($$("grida"));} }
      ]
    },
    {
      margin:10, rows:[
        { view:"button", width:110, value:"get flat PDF", click:function(){webix.toPDF($$("grida"),options);} },
        { view:"button", width:110, value:"get flat Excel", click:function(){webix.toExcel($$("grida"),options);} },
        { view:"button", width:110, value:"get flat CSV", click:function(){webix.toCSV($$("grida"),options);} }
      ]
    },
    {
      margin:10, rows:[
        { view:"button", width:110, value:"get fill PDF", click:function(){webix.toPDF($$("grida"),options2);} },
        { view:"button", width:110, value:"get fill Excel", click:function(){webix.toExcel($$("grida"),options);} },
        { view:"button", width:110, value:"get fill CSV", click:function(){webix.toCSV($$("grida"),options2);} }
      ]
    }
  ]
};

webix.ready(function(){
  webix.ui({
    margin:10, padding:10, rows:[
      {
        height:70,
        template:"<b>Export to PDF, Excel</b><br><br>Click on the button to start exporting data."
      },
      buttons,
      grida,
      {}
    ]
  });
});		
test