jQWidgets Forums
jQuery UI Widgets › Forums › ASP .NET MVC › MVC Json result Datetime format issue in grid
Tagged: #jqwidgets-grid, grid, javascript grid, jquery grid
This topic contains 3 replies, has 3 voices, and was last updated by Hristo 7 years, 9 months ago.
-
Author
-
Hi,
I am trying to use jqxgrid with date in one of the column.
Here is my ode for it.Here is a column which I added in my html.
{ text: ‘Expiration’, datafield: ‘ExpirationDate’, width: 300, cellsformat: ‘d’ },I am returning json result but I see an output like this.
/Date(1514700000000)/
how can i keep my original date to grid?Thanks,
Hello saurabhshah,
If you want to have a simple number you could set this datafield from type number.
Please, take a look at this example:var data = [ { name: 'Ian', dateString: 1514700000000 }, { name: 'Cheryl', dateString: 1614700000000 }, { name: 'Petra', dateString: 1714700000000 } ]; var source = { localdata: data, datafields: [ { name: 'firstname', map: 'name', type: 'string' }, { name: 'date', type: 'date' }, { name: 'dateString', type: 'number' } ], datatype: "array" }; var adapter = new $.jqx.dataAdapter(source, { beforeLoadComplete: (records) => { for (var i = 0; i < records.length; i += 1) { var rec = records[i]; console.log(rec.dateString); rec.date = new Date(rec.dateString); } return records; } }); $("#jqxgrid").jqxGrid({ width: 400, autoheight: true, theme: 'energyblue', source: adapter, filterable: true, columns: [ { text: 'First Name', datafield: 'firstname', columngroup: 'Name', width: '30%' }, { text: 'Order Date', datafield: 'date', cellsformat: 'dd-MM-yyyy', align: 'right', cellsalign: 'center' }, { text: 'Simple Text', datafield: 'dateString', } ] });
Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHello saurabhshah,
It is about
null
value set for some dates.
Could you clarify if it does not help you the example above?Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.