EXTJS 第二天

来源:互联网 发布:淘宝网电表箱装饰画 编辑:程序博客网 时间:2024/05/29 09:26

1.Grid排序功能是自动按ASCII码来排序的,如果要按中文来排序要该如何呢?

 

覆盖默认的排序方法,代码如下:

 

Ext.data.Store.prototype.applySort = fuction(){

if(this.sortInfo && !this.remoteSort)

{

var s = this.sortInfo,f=s.field;

var st = this.fields.get(f).sortType;

var fn = function(r1,r2)

{

var v1 =st(r1.data[f]),v2=st(r2.data[f]);

if(typeof(v1)=="string")

{

return r1.localeCompare(v2);

}

return (r1>r2)?1:((r1<r2)?-1:0);

};

this.data.sort(s.direction,fn);

if(this.snapshot && this.snapshot != this.data)

{

this.snmapshot.sort(s.direction,fn);

}

}

}

 

以上僅僅適用于2.0

原创粉丝点击