i'm using Extjs 4.1 grid panel.
i'm looking for a way to hide a column from the grid. i can use setHidden but then the user can "unhide" the column again from the menu in the column header. it seems that the hideable propery just doesnt cut it...
Ok. Eventually i did this: in the grid's "afterrender" event:
var header = pnl.down("headercontainer");
if(header != null && header["getMenu"] != null)
{
var menu=header.getMenu();
menu.on('beforeshow',function(sender,eOpts){
var menu=sender;
if(!menu.items.containsKey("columnItem"))
{
return;
}
var columnsSubMenuItem=menu.items.getByKey("columnItem");
var columnsCheckboxes=columnsSubMenuItem.menu.items["items"];
// More code here...
// See the pseudo code
});
}
now i just looped through the columns and if checkbox.text == column.get_Title() && column.get_Hideable() == true then checkbox.Show() else checkbox.Hide();
(sorry for the pseudo code, i work with a Sharpkit that is a C# to javascript convertor, so if i'd copy pasted the code it'd be harder to explain.
Note: you can do the same with the grid's enableColumnHide event.