PDA

View Full Version : Dynamic Tree grid in Extjs 4.1



madhav.msd
29 Oct 2012, 4:36 AM
Hi All,

Kindly requesting for help to make the dynamic grid add and remove execution faster. I'm having a tree grid, which has 4 static columns and after that, some dynamic columns based on the hasMany relationship data in the store.

I can able to get the grid work, but it is taking more than 3 mins to render the data. Here is my code below, and request your help to make the code execute faster(very urgent). And the data will be available only in the leaf node.

// removing the column if there is any dynamic column added
function removeColumnsIfExists(){
var headerCols=grid.getView().getGridColumns();
for(var i=4; i<headerCols.length; i++){
grid.headerCt.remove(i);
}
grid.getView().refresh();
}

// creating dynamically new column to display the date field

function createFlatStore_1(node){
removeColumnsIfExists();
if(node){
if(node.hasChildNodes()){
var children=node.childNodes;
for(var i=0;i<children.length;i++){

if(children[i].isLeaf()){

var columns = children[i].myDates();

for(var j=0;j<columns.count();j++){
column = Ext.create('Ext.grid.column.Date', {
dataIndex:'dataIndex'+j,
text: columns.getAt(j).get('title'),
format:'d/m/Y',
align: 'center',
editor: {
xtype: 'monthfield',
allowBlank: false,
format : 'd-M-Y'
},
renderer : function (value, metaData, record, row, col, store, gridView){
var pgms=record.myDates();
var dateValue;
if(pgms.count() > (col-4)) {
if(value !== undefined){
pgms.getAt(col-4).set('date', value);
pgms.getAt(col-4).setDirty();
}
dateValue = Ext.Date.dateFormat(pgms.getAt(col-4).get('date'),'d-M-Y');

}
return dateValue;
}
});

grid.headerCt.insert(grid.columns.length, column);
grid.getView().refresh();
}

break;
}

createFlatStore_1(children[i]);
}

}
}
}

mitchellsimoens
1 Nov 2012, 8:25 AM
For dynamic why don't you let it load the child nodes when you expand a node?

madhav.msd
2 Nov 2012, 3:29 AM
Thanks mitchellsimoens, for your response

By default all my nodes are expanded. And also for parent nodes the associated data length is zero. Only the leaf node will have the data.