I have:
Record config
Reader
Data Store
Column Model
and Grid
standard config.
When I click on "Publish Date" column, my backend recieves param "sort=publishDate", but I expect, that it must be "sort=publish_date".
Bug, or I'm doing something wrong?
Record config
Item = Ext.data.Record.create([
{name: 'id', mapping: 'id', type: 'int'},
{name: 'publishDate', mapping: 'publish_date', type: 'date', dateFormat: 'Y-m-d H:i:s'},
]);
reader = new Ext.data.JsonReader({
root: 'list',
totalProperty: 'totalCount',
id: 'id'
}, Item);
ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'news/getlist'}),
reader: reader,
remoteSort: true
});
ds.setDefaultSort('publish_date', 'desc');
cm = new Ext.grid.ColumnModel([{
id: 'id',
header: 'Id',
dataIndex: 'id',
width: 20
},{
id: 'publishDate', // id assigned so we can apply custom css (e.g. .x-grid-col-login b { color:#333 })
header: 'Publish Date',
dataIndex: 'publishDate',
renderer: renderPublishDate,
width: 100
}]);
cm.defaultSortable = true;
grid = new Ext.grid.Grid('news-grid', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect: true}),
enableColLock: false
});
When I click on "Publish Date" column, my backend recieves param "sort=publishDate", but I expect, that it must be "sort=publish_date".
Bug, or I'm doing something wrong?

|
#2
|
|
Is that wrong? I just have the "name" property in my Ext.data.Record (I don't know what "mapping" does!)
And in my ColumnModel, the "dataIndex" property refers to that name to get the value from the Record. I set the name to be the actual HQL (SQL) expression that generated that column, so all is well for me... I don't want this to change! ![]() |
|
#3
|
|
Arikon, please don't make a new thread for everything you think is a bug.
This has been discussed before and it is not a bug. For your mapping (a simple string name) it may make sense, but everyone's may not be as simple. For example, sending: 'Item/Name[@type]' back to the server would be worthless. ![]() |
本文探讨了使用ExtJS框架创建网格时遇到的排序问题,具体表现为后台接收的排序参数与预期不符的情况。作者详细展示了配置记录、读取器、数据存储及列模型的过程,并针对点击列头进行排序时出现的问题进行了讨论。

被折叠的 条评论
为什么被折叠?



