PDA

View Full Version : Grid sort problem



SauronTNT
6 Sep 2012, 11:00 PM
Hi

i have a strange behavior in the sort of my grid :-?. I have 5 columns, the 2 first one can be sorted without issue, the 3 last are never sorted correctly

here is the code of the store


var affectedCIstore = new Ext.data.Store({
id: 'affectedCIstore'
, autoLoad: true
//, sortInfo: { field: "IMPACTTEXT", direction: "ASC" }
, proxy: new Ext.data.HttpProxy({
url: '/cmo/wservices/CmoService.asmx/GetRequestCIs'
, jsonData: { thisrequest: thisrequest} //for FF
, method: 'post'
, headers: { 'Content-Type': 'application/json;charset=utf-8' }
})
, reader: new Ext.ux.NetJsonReader({ id: 'LOGICAL_NAME' }, [
{ name: 'CI', mapping: 'CI' }
, { name: 'IMPACT', mapping: 'IMPACT' }
, { name: 'EVENT_START', mapping: 'EVENT_START' }
, { name: 'EVENT_END', mapping: 'EVENT_END' }
, { name: 'IMPACTTEXT', mapping: 'IMPACTTEXT' }
, { name: 'UCMDB_ID', mapping: 'UCMDB_ID' }
]
)
});



and the code of the grid



var affectedCIgrid = new Ext.grid.GridPanel({
store: affectedCIstore,
id: 'gridAffectedCI',
autoHeight: false,
maxHeight: 160,
height: 200,
layout: 'auto',
style: "margin:1px;padding:0px;margin-top:0px;",
headerCfg: { style: "background:lightyellow;height:17px;padding:2px;" },
bodyStyle: "border:1px;background-color:aliceblue",
title: 'Affected Cis ' + Ext.get("CiCount").dom.innerHTML,
autoScroll: true,
collapsible: true,
border: false,
collapsed: true,
titleCollapse: true,

colModel: new Ext.grid.ColumnModel({
defaults: {
sortable: true
},
columns: [
{ header: 'Configuration Item', sortable: true, width: 200, dataIndex: 'CI', renderer: renderSCMUrl },
{ header: 'Outage', sortable: true, dataIndex: 'IMPACTTEXT' },
{ header: 'Event Start', sortable: true, width: 150, dataIndex: 'EVENT_START', type:'string' },
{ header: 'Event End', sortable: true, width: 150, dataIndex: 'EVENT_END' },
{ header: 'Ucmdb', width: 100, sortable: true, dataIndex: 'UCMDB_ID', hidden: false, renderer: renderUCMDBUrl }
]
}),
sm: new Ext.grid.RowSelectionModel({ singleSelect: true })
});


Column 2 is string
Column 3 & 4 are datetime
Column 1 & 5, the render return a <a> html tagthe

grid sort for column 3, 4 & 5 are like a random sort :-)
if you have an idea of what i am wrong, it will nice :">

willigogs
7 Sep 2012, 12:41 AM
You don't appear to have set what type your store fields are?
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.Field-cfg-type

In some circumstances (especially dates), you may also need to give your columns xtypes:
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.grid.Column-cfg-xtype

:)

SauronTNT
7 Sep 2012, 5:54 AM
Thanks when I add type of data, the sort work better now :-)

Last, do you know where can I found all date format available in sencha 3.4 ?

willigogs
7 Sep 2012, 7:33 AM
http://docs.sencha.com/ext-js/3-4/#!/api/Date

SauronTNT
9 Sep 2012, 11:39 PM
Thanks a lot

I forgot everytime the basics ==> RQFM ( Read the ing manual :D )