Changing the structure of datagrids dojo dynamically

I am having trouble trying to change the structure of a datagrid after receiving new information. I need to be able to change the number of columns with each query.

The javascript code that I use to create the grid

function setgrid(){ var gridLayout = []; var key, i; for(i = 0; i < 10; i++) { key = i + ""; gridLayout.push({ field: key, name: key, editable: false }); } // create a new grid: billsGrid = new dojox.grid.DataGrid({ query: {}, //store: store, clientSort: true, rowSelector: '20px', structure: gridLayout, columnReordering: true }, gridContainer); // Call startup, in order to render the grid: billsGrid.startup(); } 

and html:

 <div id="gridContainer" style="width: 650px; height: 600px; border: 1px solid silver;" /> 

How do I change the grid to have a new layout of 5 columns?

+4
source share
2 answers

I found this, I just needed to know what to call in order to apply the new layout to the existing grid. In this case: billsGrid.setStructure(newLayout);

+8
source

There is no setStructure method in the latest version of dojo. You can use:

 grid.set('structure', newStructure); 
+1
source

All Articles