排序我是新來的內線,所以我提前道歉,如果我的問題是不夠清晰/太基本...由呈現值一個ExtJS 3 EditorGridPanel
我有一個Ext.grid.EditorGridPanel與Ext.data.Store和一個Ext.data.JsonReader。
我有以下問題:
我想對我做網格列排序,但是從我的店裏返回的值是不是我想作爲排序依據的值(返回的值是一個ID我想按照這個ID映射到的字符串排序)。
我有一個渲染函數,可以在這個ID和字符串值之間進行轉換,但我不知道如何將它集成到我的代碼中。
我發現這個帖子:
http://www.sencha.com/forum/showthread.php?45324-Grid-column-sorting-on-rendered-value
這看起來類似於我的需要,但是當我嘗試添加:
{name: 'my_field', sortType: my_render_function}
我JsonReader沒有奏效。
我在哪裏弄錯了?
謝謝。
對於佩特的要求:
var my_render = function(val, metaData, record, rowIndex, colIndex, store){
if (val == null)
return '';
var n = another_store.getById(val);
if (n == null)
return '';
return n.data.name;
};
var my_reader = new Ext.data.JsonReader({
root: 'my_root',
id: 'tissue_num',
}, [{
name: 'tissue_num',
type: 'int'
}, 'tissue_desc', 'organ']
);
var my_store = new Ext.data.Store({
url: request_url,
baseParams: {
_state: request_state,
_action: 'get_conditions'
},
sortInfo: {
field: 'tissue_num',
direction: "ASC"
},
reader: my_reader,
pruneModifiedRecords: true
});
你能提供一些代碼嗎?排序功能和JSON閱讀器? – pater 2012-03-19 15:43:03