PDA

View Full Version : sorting not working on date column in grid



gmuser
25 Nov 2014, 12:51 PM
Sorting not working properly for date column in a grid
{
xtype: 'panel',
frame: false,
border: true,
widthRatio: 0.70,
flex: 1,
layout:'fit',
autoScroll: true,


items :[{
xtype: 'gridpanel',
store: 'RFQInfoGridStore',
width: '100%',
itemId: 'RFQInfoGridId',
flex: 1,
columns:[
{
text: 'Respond By Date',
flex: 1,
dataIndex: 'rfqResponseDueDate',
xtype: 'datecolumn',
dateFormat: 'Y-m-d',
sortable: true
}],
}

---- Following is the data model----
Ext.define('GPS.model.RFQInfoGridModel', {
extend: 'Ext.data.Model',
fields: [
{name:'rfqResponseDueDate', type:'date', dateFormat:'Y-m-d'}
]


});

Value that is returned from server in JSON response is 2014-10-01

joel.watson
25 Nov 2014, 1:24 PM
Hi gmuser--

It seems to be working for me. Can you check the fiddle below and see if you're still getting the issue?

Thanks

e0t

gmuser
25 Nov 2014, 3:06 PM
Hello, thanks for response.
I am looking into it why it doesnt work on my app.
However please check the fiddle, I have added another column which is not sorting. could you please check what am I missing?

https://fiddle.sencha.com/#fiddle/e0t

Thanks

joel.watson
25 Nov 2014, 3:08 PM
I don't see the new column. You'll have to fork my fiddle and then post the link to your changes.

Thanks!

gmuser
25 Nov 2014, 3:09 PM
It is asking for a password to fork it.

gmuser
25 Nov 2014, 3:11 PM
Ext.define('Store', {
extend: 'Ext.data.Store',
fields: [{name: 'date1', type: 'date', dateFormat: 'Y-m-d'},
'firstname'],
data: [{
date1: '2014-10-01', firstname: 'aname'
}, {
date1: '2014-09-01',firstname: 'bname'
}, {
date1: '2014-08-01',firstname: 'cname'
}, {
date1: '2013-10-01', firstname: 'dname'
}]
})
Ext.application({
name: 'Fiddle',


launch: function() {
var store = Ext.create('Store');
Ext.create('Ext.grid.Panel', {
store: store,
columns: [{
xtype: 'datecolumn',
text: 'Date',
dataIndex: 'date1',
format: 'Y-m-d',
sortable: true,
flex: 1
},{
text: 'Buyer Name',
xtype:'templatecolumn',
tpl:'{firstname}',
flex: 1,
sortable: true
}
],
width: 400,
renderTo: document.body
})
}
});

joel.watson
25 Nov 2014, 3:15 PM
See the updated fiddle: seems to be working for both as expected. Can you share your actual grid definition?

Thanks

gmuser
25 Nov 2014, 7:43 PM
Ext.define('GPS.store.RFQInfoGridStore', {
extend: 'Ext.data.Store',


requires: ['Ext.data.proxy.Ajax','GPS.model.RFQInfoGridModel'],


model: 'GPS.model.RFQInfoGridModel',

autoLoad: true, /*{start: 0, limit: 8},*/
sortOnLoad: false,
defaultPageSize: null,

groupField: 'actionPlanNumber',

remoteFilter : true,


proxy: {
type: 'ajax',
url: 'rest/actionplan/search',
reader: {
type: 'json',
root: 'result.actionPlanInfo'
}
},

showWarning: false,

listeners: {
load: function (store, records, successfull) {
if ( this.showWarning )
if ((successfull) && (records.length == 0)) { Ext.Msg.alert('Info','No data matching criteria'); }
this.showWarning = true;
}
}
});


-------------------------------------------

Ext.define('GPS.model.RFQInfoGridModel', {
extend: 'Ext.data.Model',


fields: [
'actionPlanNumber',
{name:'initiatingBuyerFirstName', type:'string'},
{name:'initiatingBuyerLastName', type:'string'},
{name:'rfqResponseDueDate', type:'date', dateFormat:'Y-m-d'},
'roundNumber',
'orgId',
'supplierType',
//'rfqResponseDueDate',
'usageStatus',
'bidderInfoListStr',
'actionPlanStatusCd'

]


});

joel.watson
26 Nov 2014, 1:53 PM
Ok, so I see that you have remoteFilter set to true on your store. Are you handling that on the server-side (which is what's expected when remoteFilter is true)?

mdarretta
23 Feb 2016, 11:49 AM
it works when year is first field but for format m/d/Y it does not work.