【发布时间】:2012-04-04 01:36:38
【问题描述】:
我是 Ext 的新手,所以如果我的问题不够清楚/太基本,我提前道歉......
我有一个带有 Ext.data.Store 和 Ext.data.JsonReader 的 Ext.grid.EditorGridPanel。
我有以下问题:
我想让我的网格中的列可排序,但从我的商店返回的值不是我想要排序的值(返回的值是一个 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 阅读器?