Let's move on and add a grid to the right lower cell of the layout and load data into it. Data source for the grid will contain reports for profits and losses for the last N years and will be specified in the XML format.
Data items of the source will have 5 properties:
<rows>
<row id="1">
<cell>2002</cell>
<cell>I</cell>
<cell>270538</cell>
<cell>170832</cell>
<cell>Sipho Garz</cell>
</row>
...
</rows>
As a result, our grid will contain 5 columns, each of which will correspond to an individual data property.
We will use the dhtmlxGrid component to present data in a tabular form on the page.
"index.html" file
var layout = new dhtmlXLayoutObject(document.body,"3L");
var grid = layout.cells("c").attachGrid();;
"index.html" file
grid.setImagePath("codebase/imgs/"); //sets the path to the source images
grid.setHeader("Year,Quarter,Profits per quarter ($),Losses per quarter ($),"+
"A person responsible for the data"); //sets the columns' headers
grid.setColTypes("ro,ro,ro,ro,ro"); //sets the types of columns
grid.setInitWidths("100,150,230,230,*"); //sets the initial widths of columns
grid.setColAlign("center,center,center,center,center"); //sets the x alignment
"index.html" file
grid.init();
"index.html" file
grid.init();
grid.load("data/gridData.xml");