Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing a dojo datagrids structure dynamically

I am having trouble attempting to change the structure of a datagrid after new information is received. I need to be able to change the number of columns everytime a query is made.

The javascript code 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 the html:

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

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

like image 310
Glen Van Der Poel Avatar asked Jan 21 '23 23:01

Glen Van Der Poel


2 Answers

Found it, just needed to know what to call to apply a new layout to the existing grid. In this case: billsGrid.setStructure(newLayout);

like image 76
Glen Van Der Poel Avatar answered Jan 23 '23 11:01

Glen Van Der Poel


In the latest version of dojo, there is no method setStructure. You might want to use:

grid.set('structure', newStructure);
like image 40
always_a_rookie Avatar answered Jan 23 '23 13:01

always_a_rookie