Hiding Columns In cfrgids Column Context Menu
Wednesday March 5, 2008 4:48 PM
Word Count:
286
I have been showing you how to extend the cfgrid component lately by tapping into the Ext framework. Earlier I wrote a tutorial about creating context menus. Henry liked it but had one concern, lets look at his question.
How do u hide CFGRIDROWINDEX in header context menu -> Columns ? Without the ability to hide that, it is just not acceptable to use that feature as site user might find that confusing, especially when selectmode="edit"
Basically when you right click on the grids column header a menu will popup, in that menu their is a list of columns with check boxes next to the name so that you can hide/show columns in the grid. I can see why we need to hide the gridRowIndex. If someone has a better solution please let me know but I found a solution for this problem. Before the list of columns is shown we can loop over the list and search for the column we want to remove. Once we find the column simply use the menus remove method.
grid.view.colMenu.addListener("beforeshow", function(menu){
var grid = ColdFusion.Grid.getGridObject("ArtistGrid");
var cm = grid.getColumnModel();
var count = cm.getColumnCount();
for(var i = 0; i < count; i++){
if("CFGRIDROWINDEX" == cm.getDataIndex(i)) {
menu.remove(menu.items["items"][i]);
break;
}
}
});
var grid = ColdFusion.Grid.getGridObject("ArtistGrid");
var cm = grid.getColumnModel();
var count = cm.getColumnCount();
for(var i = 0; i < count; i++){
if("CFGRIDROWINDEX" == cm.getDataIndex(i)) {
menu.remove(menu.items["items"][i]);
break;
}
}
});
