PDA

View Full Version : How to achieve automatic row numbering for tree grid.



sarasa
16 Apr 2013, 3:16 AM
Hi,

Could you please let me know how to achieve automatic row numbering for tree grid.

slemmon
17 Apr 2013, 3:40 PM
You can pick apart the treegrid (http://docs.sencha.com/extjs/4.2.0/#!/example/build/KitchenSink/ext-theme-neptune/#tree-grid) example and add a rownumberer (http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.grid.RowNumberer) column.




var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{ text: "detention", leaf: true },
{ text: "homework", expanded: true, children: [
{ text: "book report", leaf: true },
{ text: "algebra", leaf: true}
] },
{ text: "buy lottery tickets", leaf: true }
]
}
});


Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 150,
store: store,
rootVisible: false,
renderTo: Ext.getBody()
, columns: [{
xtype: 'rownumberer'
}, {
xtype: 'treecolumn', //this is so we know which column will show the tree
text: 'Task',
flex: 1,
sortable: true,
dataIndex: 'text'
}]
});