PDA

View Full Version : the gridpanel can't sort if response json datetime



lee1430
10 Mar 2009, 7:31 AM
response json data:

[{"WORKER_TYPE_NAME":"BANJIN","WORKER_TYPE_ID":1,"UPDATE_IP":null,"UPDATE_BY":null,"CREATE_IP":"localhost/127.0.0.1/null","CREATE_BY":null,"PIS_USER_ID":64172154,"UPDATE_DATE":null,"CREATE_DATE":{"hours":23,"minutes":41,"seconds":0,"date":8,"year":109,"time":1236526860000,"day":0,"timezoneOffset":-480,"month":2},"WORKER_TYPE_CODE":"BJ","REMARK":"BANJINLEI"},{"WORKER_TYPE_NAME":"PENQI","WORKER_TYPE_ID":16,"UPDATE_IP":"localhost/127.0.0.1/null","UPDATE_BY":null,"CREATE_IP":"localhost/127.0.0.1/null","CREATE_BY":null,"PIS_USER_ID":64172154,"UPDATE_DATE":{"hours":22,"minutes":17,"seconds":28,"date":10,"year":109,"time":1236694648000,"day":2,"timezoneOffset":-480,"month":2},"CREATE_DATE":{"hours":21,"minutes":18,"seconds":52,"date":10,"year":109,"time":1236691132000,"day":2,"timezoneOffset":-480,"month":2},"WORKER_TYPE_CODE":"PQ","REMARK":"PENGQILEI"},{"WORKER_TYPE_NAME":"TEST","WORKER_TYPE_ID":17,"UPDATE_IP":null,"UPDATE_BY":null,"CREATE_IP":"localhost/127.0.0.1/null","CREATE_BY":null,"PIS_USER_ID":64172154,"UPDATE_DATE":null,"CREATE_DATE":{"hours":22,"minutes":32,"seconds":57,"date":10,"year":109,"time":1236695577000,"day":2,"timezoneOffset":-480,"month":2},"WORKER_TYPE_CODE":"TEST","REMARK":"TEST"},{"WORKER_TYPE_NAME":"TEST","WORKER_TYPE_ID":18,"UPDATE_IP":null,"UPDATE_BY":null,"CREATE_IP":"localhost/127.0.0.1/null","CREATE_BY":null,"PIS_USER_ID":64172154,"UPDATE_DATE":null,"CREATE_DATE":{"hours":22,"minutes":32,"seconds":58,"date":10,"year":109,"time":1236695578000,"day":2,"timezoneOffset":-480,"month":2},"WORKER_TYPE_CODE":"TEST","REMARK":"TEST"},{"WORKER_TYPE_NAME":"TEST","WORKER_TYPE_ID":19,"UPDATE_IP":null,"UPDATE_BY":null,"CREATE_IP":"localhost/127.0.0.1/null","CREATE_BY":null,"PIS_USER_ID":64172154,"UPDATE_DATE":null,"CREATE_DATE":{"hours":22,"minutes":32,"seconds":58,"date":10,"year":109,"time":1236695578000,"day":2,"timezoneOffset":-480,"month":2},"WORKER_TYPE_CODE":"TEST","REMARK":"TEST"},{"WORKER_TYPE_NAME":"TEST","WORKER_TYPE_ID":20,"UPDATE_IP":null,"UPDATE_BY":null,"CREATE_IP":"localhost/127.0.0.1/null","CREATE_BY":null,"PIS_USER_ID":64172154,"UPDATE_DATE":null,"CREATE_DATE":{"hours":22,"minutes":32,"seconds":59,"date":10,"year":109,"time":1236695579000,"day":2,"timezoneOffset":-480,"month":2},"WORKER_TYPE_CODE":"TEST","REMARK":"TEST"},{"WORKER_TYPE_NAME":"TEST","WORKER_TYPE_ID":21,"UPDATE_IP":null,"UPDATE_BY":null,"CREATE_IP":"localhost/127.0.0.1/null","CREATE_BY":null,"PIS_USER_ID":64172154,"UPDATE_DATE":null,"CREATE_DATE":{"hours":22,"minutes":32,"seconds":59,"date":10,"year":109,"time":1236695579000,"day":2,"timezoneOffset":-480,"month":2},"WORKER_TYPE_CODE":"TEST","REMARK":"TEST"}]

the "UPDATE_DATE" is a json date :"UPDATE_DATE":{"hours":22,"minutes":17,"seconds":28,"date":10,"year":109,"time":1236694648000,"day":2,"timezoneOffset":-480,"month":2},"

the "UPDATE_DATE" fileds of Ext.data.JsonReader is:
{
name : 'UPDATE_DATE',
mapping : 'UPDATE_DATE'
}

the "UPDATE_DATE" config of Ext.grid.ColumnModel is:
{
header:WorkerTypeManage_i18n.TAG_08,
dataIndex:"UPDATE_DATE",
width:130,
renderer:function(value, metadata, record, rowIndex, colIndex, store){
if(value == null){
return ''
}else{
return Ext.util.Format.date(new Date(value.time), 'Y-m-d H:i:s')
}
},
sortable:true
}

the example after loaddata, but "UPDATE_DATE" field is not sorted, please help me, thank you:
http://www.extjs.com/forum/attachment.php?attachmentid=12416&stc=1&d=1236698986

Animal
10 Mar 2009, 8:01 AM
Are you explicitly typing the Field as a Date?

http://extjs.com/deploy/dev/docs/?class=Ext.data.Record&member=create

Animal
10 Mar 2009, 8:02 AM
I assume that screenshot you click descending and it didn't work?