Ext.data.Store.prototype.applySort = function() { // 重載 applySort
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]);
// 添加:修復(fù)漢字排序異常的Bug
if (typeof(v1) == "string") { // 若為字符串,
// 則用 localeCompare 比較漢字字符串, Firefox 與IE 均支持
return v1.localeCompare(v2);
}
// 添加結(jié)束
return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
};
this.data.sort(s.direction, fn);
if (this.snapshot && this.snapshot != this.data) {
this.snapshot.sort(s.direction, fn);
}
}
};