if(g.enableColumnHide !== false){
if (this.cm.config.length > 0) {
// Build count of columns that do not have menu disabled
var colCount = 0;
for (var i = 0; i < this.cm.config.length; i++) {
if (this.cm.config[i].menuDisabled == false) colCount++;
}
// Build count of columns that are hideable
var hideCount = 0;
for (var i = 0; i < this.cm.config.length; i++) {
if (this.cm.config[i].hideable == false) hideCount++;
}
//
if (hideCount < colCount) {
this.hmenu.add('-',
{id:"columns", text: this.columnsText, menu: this.colMenu, iconCls: 'x-cols-icon'}
);
}
}
}
看隐藏前后的图片:

修改前

修改后
下面是override Ext grid的代码:
Ext.override(Ext.grid.GridView,{
renderUI : function(){
var header = this.renderHeaders();
var body = this.templates.body.apply({rows:''});
var html = this.templates.master.apply({
body: body,
header: header
});
var g = this.grid;
g.getGridEl().dom.innerHTML = html;
this.initElements();
// get mousedowns early
Ext.fly(this.innerHd).on("click", this.handleHdDown, this);
this.mainHd.on("mouseover", this.handleHdOver, this);
this.mainHd.on("mouseout", this.handleHdOut, this);
this.mainHd.on("mousemove", this.handleHdMove, this);
this.scroller.on('scroll', this.syncScroll, this);
if(g.enableColumnResize !== false){
this.splitZone = new Ext.grid.GridView.SplitDragZone(g, this.mainHd.dom);
}
if(g.enableColumnMove){
this.columnDrag = new Ext.grid.GridView.ColumnDragZone(g, this.innerHd);
this.columnDrop = new Ext.grid.HeaderDropZone(g, this.mainHd.dom);
}
if(g.enableHdMenu !== false){
if(g.enableColumnHide !== false){
this.colMenu = new Ext.menu.Menu({id:g.id + "-hcols-menu"});
this.colMenu.on("beforeshow", this.beforeColMenuShow, this);
this.colMenu.on("itemclick", this.handleHdMenuClick, this);
}
this.hmenu = new Ext.menu.Menu({id: g.id + "-hctx"});
this.hmenu.add(
{id:"asc", text: this.sortAscText, cls: "xg-hmenu-sort-asc"},
{id:"desc", text: this.sortDescText, cls: "xg-hmenu-sort-desc"}
);
if(g.enableColumnHide !== false){
if (this.cm.config.length > 0) {
// Build count of columns that do not have menu disabled
var colCount = 0;
for (var i = 0; i < this.cm.config.length; i++) {
if (this.cm.config[i].menuDisabled == false) colCount++;
}
// Build count of columns that are hideable
var hideCount = 0;
for (var i = 0; i < this.cm.config.length; i++) {
if (this.cm.config[i].hideable == false) hideCount++;
}
//
if (hideCount < colCount) {
this.hmenu.add('-',
{id:"columns", text: this.columnsText, menu: this.colMenu, iconCls: 'x-cols-icon'}
);
}
}
}
this.hmenu.on("itemclick", this.handleHdMenuClick, this);
//g.on("headercontextmenu", this.handleHdCtx, this);
}
if(g.trackMouseOver){
this.mainBody.on("mouseover", this.onRowOver, this);
this.mainBody.on("mouseout", this.onRowOut, this);
}
if(g.enableDragDrop || g.enableDrag){
this.dragZone = new Ext.grid.GridDragZone(g, {
ddGroup : g.ddGroup || 'GridDD'
});
}
this.updateHeaderSortState();
}
});
声明:本站教程文章版权为一起Ext(http://www.17ext.com/)所有,转载请注明出处