jQuery UI Widgets › Forums › Grid › Date column in grid show as number
This topic contains 6 replies, has 3 voices, and was last updated by aravindtrue 12 years, 2 months ago.
-
Author
-
Hi,
Just started with jqWidget. Works like a charm. Without too much coding it renders records coming from the server. However, I’m having difficulties getting dates to print properly.
The date column setup is:
datafields:
{ name: 'uploadDt', type: 'date'},
columns:
{ text: 'Upload Date', datafield: 'uploadDt', width: 150, cellsformat: 'D'},
JSON data:
...
[{"id":46,"fileName":"upload_res.xls","securityId":2,"createdBy":5,"creationDt":1334872800000,"updatedBy":5,"updatedDt":1334872800000,"fileType":"Excel","uploadDt":1334872800000,"uploadStatus":"SUCCESS","uploadMessage":"File uploaded"},
...
The ‘uploadDt’ column comes from a timestamp column in my db. I’m assuming that the ‘type’ and ‘cellsformat’ settings should somehow trigger a conversion but I’m seeing ‘1334872800000’ as the column value. I must be doing something wrong. Any suggestions are greatly appreciated.
Thank & rgds,
MartinHi Martin,
Thanks for writing.
I tested the provided code and observed that the conversion of ‘1334872800000’ to Date object failed. That’s the reason the Grid displays the timestamp value as a Number instead of Date. This is an issue in the built-in Date object parsing of timestamp values and it will be resolved in the upcoming release.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Thanks for the quick response. I’ll work around it by converting it to string and wait for the next release. Any idea on the date?
Kind regards,
MartinHi Martin,
The release is currently scheduled for 05/05/2012. However there could be a small delay in a few days depending on the QA work.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
I am using version 2.4.1 and still facing this problem. Is this resolved?
Regards,
AravindHi Aravind,
The issue is fixed. See online demo here: http://jsfiddle.net/jqwidgets/LNBEN/1/
Here’s a code snippet:
var data = [{ "id": 46, "fileName": "upload_res.xls", "securityId": 2, "createdBy": 5, "creationDt": 1334872800000, "updatedBy": 5, "updatedDt": 1334872800000, "fileType": "Excel", "uploadDt": 1334872800000, "uploadStatus": "SUCCESS", "uploadMessage": "File uploaded"}];var source = { localdata: data, datatype: "json", datafields: [{ name: 'uploadDt', type: 'date'}]};var dataAdapter = new $.jqx.dataAdapter(source);$("#jqxgrid").jqxGrid({ source: dataAdapter, columnsresize: true, columns: [ { text: 'Name', dataField: 'uploadDt', cellsformat: 'd'} ]});​
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comPerfect. This is great.. 🙂
I was working in version 2.4.1 and the demo is having 2.4.2.
And missed out the ‘type’ for datafields.
Thanks a lot for helping me out.
Regards,
Aravind -
AuthorPosts
You must be logged in to reply to this topic.