-
22 Apr 2012 10:47 PM #1
extjs date column grid panel format issue. {"updatedOn":1335156222983} - json data.
extjs date column grid panel format issue. {"updatedOn":1335156222983} - json data.
Hello Team,
I am trying to display the createdOn and updatedOn in the grid panel and I am not able to render it on the grid. Any suggestions/pointers to solve this problem would be appreciable.
When I looked into the database code, I have seen the service while inserting the updatedOn or createdOn, they are creating a calendar.getInstance().getTime() and storing the value and return value from the service is in the Date.
my json data is as follows:
{"totalRecords":1,"errorMessage":null,"success":null,"vanityUrls":[{"description":"","locale":"EN_FR","updatedBy":"","vanityUrl":"rediff","linkUrl":"rediff.com","updatedOn":1335156222983,"linkId":29944,"createdBy":"","businessUnitId":0,"sourceCode":"","comments":"rediff1","linkType":8,"divisionId":0}]}
model fields for date, createOn and updatedOn:
Ext.define('VanityUrl', {
extend: 'Ext.data.Model',
idProperty:'linkId',
fields: [
{name: 'createdOn', type: 'date', dateFormat: 'Y-m-d H:i
.u'}, // not sure I am doing correct. please suggest.
{name: 'updatedOn', type: 'date', dateFormat: 'Y-m-d H:i
.u'}// not sure I am doing correct. please suggest.
]
});
column definition in grid panel store.
{
header: "Updated On",
width: 100,
sortable: true,
dataIndex: 'updatedOn',
renderer: Ext.util.Format.dateRenderer('Y-m-d') // not sure I am doing correct. please suggest.}
--Durga
-
23 Apr 2012 12:04 AM #2
It seems that updatedOn is milisecond timestamp. If so, you should define dateFormat as 'time'Code:{"totalRecords":1,"errorMessage":null,"success":null,"vanityUrls":[{"description":"","locale":"EN_FR","updatedBy":"","vanityUrl":"rediff","linkUrl":"rediff.com","updatedOn":1335156222983,"linkId":29944,"createdBy":"","businessUnitId":0,"sourceCode":"","comments":"rediff1","linkType":8,"divisionId":0}]}
Code:Ext.define('VanityUrl', { extend: 'Ext.data.Model', idProperty:'linkId', fields: [ {name: 'createdOn', type: 'date', dateFormat: 'time'}, {name: 'updatedOn', type: 'date', dateFormat: 'time'} ] });
-
23 Apr 2012 6:55 AM #3
Thanks vietits for your response. Always your replies just fit into my solution straight. I appreciate your knowledge and time sir.
--Durga
-
18 Oct 2012 4:02 AM #4
not working for me
not working for me
My grid :
header : "Processed Date",
dataIndex : 'processedDate',
sortable : false,
renderer: Ext.util.Format.dateRenderer('d-m-Y'),
Model:
'processedDate', {
name : 'date',
type: 'date',
dateFormat: 'time'
}
processdDate is coming via json in this format :1350560184000
Help me....already have tried with many thing....
-
18 Oct 2012 4:58 AM #5
@ jnkrana,
What is your problem? It's better to post your complete code instead of just a piece of code and try to put them in CODE tag.
-
18 Oct 2012 5:36 AM #6
I am having same issue with above posted by Durga.
I have pasted my grid column and model data but not working at all based on your solution.
On grid, its shows me like this ...NaN-Nan-Nan...
Let me know how can you help me.
-
18 Oct 2012 5:47 AM #7
You should post your complete model, grid and json data for getting help. I don't understand your model code:
Code:'processedDate', { name : 'date', type: 'date', dateFormat: 'time' }
-
18 Oct 2012 10:26 PM #8
here you go...
Model:
grid :Code:Ext.define('ImageModel', { extend : 'Ext.data.Model', idProperty : 'RecordNumber', fields : [ 'exceptionNumber', 'filename', 'recordNumber', { name : 'size', type : 'float' }, 'processedDate', { name : 'date', type: 'date', dateFormat: 'time' }], });
let me know how can you help me..Code:xtype: 'gridpanel', title : 'Exception List', store : exceptionstore, columns : [ { header : 'Sr.No.', xtype: 'rownumberer', width: 50, sortable: false },{ header : "Exception Number", dataIndex : 'exceptionNumber', sortable : false, }, { header : "Record Number", dataIndex : 'recordNumber', sortable : false, }, { header : "Processed Date", dataIndex : 'processedDate', sortable : false, renderer: Ext.util.Format.dateRenderer('d-m-Y'), } ],
-
19 Oct 2012 5:56 AM #9
You did not define type for the processedDate field so it will be set to auto by default.
Try to fix your code as below:
Code:Ext.define('ImageModel', { extend : 'Ext.data.Model', idProperty : 'RecordNumber', fields : [ 'exceptionNumber', 'filename', 'recordNumber', { name : 'size', type : 'float' }, // 'processedDate', { name : 'processedDate', type: 'date', dateFormat: 'time' }, { name : 'date', type: 'date', dateFormat: 'time' } ] });
-
21 Oct 2012 8:50 PM #10


Reply With Quote
and silly mistake... 