`
runfeel
  • 浏览: 904856 次
文章分类
社区版块
存档分类
最新评论

禁用Extjs中propertyGrid的自动排序

 
阅读更多

书上讲的解决办法是直接修改Extjs中的ext-all.js文件,注释掉里面的b.store.sort("name", "ASC");这句代码。

这样虽然能达到效果,但是如果有的propertyGrid需要这种自动排序的功能,岂不是不行!

既然要修改源代码,那么就不要修改得这样死,废话不说了,开始吧!

我们可以在propertyGrid上增加一个配置属性,标识是否需要自动排序,比如就叫autoSort,初始值设置为true,在我们new propertyGrid的时候,如果不想自动排序,那么就配置autoSort的值为false,这样就能达到我们想要的效果了!

具体的代码如下:

Ext.grid.PropertyGrid = Ext.extend(Ext.grid.EditorGridPanel, {autoSort:true,enableColumnMove:false,stripeRows:false,trackMouseOver:false,clicksToEdit:1,enableHdMenu:false,viewConfig:{forceFit:true},initComponent:function() {
this.customEditors = this.customEditors || {};
this.lastEditRow = null;
var b = new Ext.grid.PropertyStore(this);
this.propStore = b;
var a = new Ext.grid.PropertyColumnModel(this, b);
this.addEvents("beforepropertychange", "propertychange");
this.cm = a;
this.ds = b.store;
if (this.autoSort) {
b.store.sort("name", "ASC");
}
Ext.grid.PropertyGrid.superclass.initComponent.call(this);

……

使用时:
var processPropertyGrid = new Ext.grid.PropertyGrid({
id:'process-PropertyGrid',
title:'工序属性表',
closable:false,
height:400,
autoScroll:true,
autoSort:false
});

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics