PDA

View Full Version : [1.0a2 Rev 5] Grid sorting



Arikon
28 Feb 2007, 2:25 AM
I have:

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

reader = new Ext.data.JsonReader({
root: 'list',
totalProperty: 'totalCount',
id: 'id'
}, Item);


Data Store

ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'news/getlist'}),
reader: reader,
remoteSort: true
});
ds.setDefaultSort('publish_date', 'desc');

Column Model

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;

and Grid

grid = new Ext.grid.Grid('news-grid', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect: true}),
enableColLock: false
});

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?

Animal
28 Feb 2007, 2:37 AM
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!

jack.slocum
28 Feb 2007, 9:38 AM
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.