Adding ExtJS Row Numbering to ColdFusion cfgrid
With the release of ExtJS 3.0 and the ColdFusion 9 beta I have been digging into the library more. One of the libraries for the grids that ExtJS Core offers is Numbering the grid rows on the current page. ColdFusion doesn't have that option, so I decided to implement it. It was quite simple actually.
Note: This was all done on ColdFusion 9 beta and Ext JS 3.0. ColdFusion 8 ships with ExtJS 1.1 and I am not sure whether the RowNumberer class was present in version 1.1 or not. Also, since we don't have a ColdFusion 9 beta host (or if there is one I haven't found it), you will have to do with screenshots.
So, here is how the grid looks (and this thing looks a lot better than the ColdFusion 8 grid)
1 <cfset AjaxOnLoad("gridSmash")>
The gridSmash function then gets the grid and the column model for the grid. Then it gets our new RowNumberer column and adds it to the grid configuration. We use the splice method and add it to position 0 of the config array.
1 function gridSmash()
2 {
3 grid = ColdFusion.Grid.getGridObject('usersgrid');//Our Grid
4 cols = grid.getColumnModel();//Grid's Column Model
5 configA = cols.config;//Column Model Configuration
6 newcolumn = new Ext.grid.RowNumberer(); //Our new Row Numbering Column
7 temp = configA.splice(0,0,newcolumn);//Add the new column to the configuration at position 0 (first column)
8
9 }
Download Full Source:
2 {
3 grid = ColdFusion.Grid.getGridObject('usersgrid');//Our Grid
4 cols = grid.getColumnModel();//Grid's Column Model
5 configA = cols.config;//Column Model Configuration
6 newcolumn = new Ext.grid.RowNumberer(); //Our new Row Numbering Column
7 temp = configA.splice(0,0,newcolumn);//Add the new column to the configuration at position 0 (first column)
8
9 }
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
[Add Comment]
[Subscribe to Comments]
# Posted By Steve Caldwell
| 2/3/10 12:11 PM
[Add Comment]