jQWidgets Forums
jQuery UI Widgets › Forums › Grid › $.jqx.dataFormat.isData functionality
Tagged: dataFormat isDate JsonResult
This topic contains 4 replies, has 2 voices, and was last updated by Peter Stoev 9 years, 1 month ago.
-
Author
-
Hi, I’m using the following code:
function FormatValue(column, value) { if (value == undefined) return 'NA'; if (column.CellsFormat != '') { if ($.jqx.dataFormat) { if ($.jqx.dataFormat.isDate(value)) { value = $.jqx.dataFormat.formatdate(value, column.CellsFormat); } else if ($.jqx.dataFormat.isNumber(value)) { value = $.jqx.dataFormat.formatnumber(value, column.CellsFormat); } } } return value; }
which I think worked as expected on a prior version of jQWidgets but doesn’t work on the current version (V4.1.2)
I’m calling it with:
column.CellsFormat = "S" value = "/Date(1464635185000)/"
the function:
$.jqx.dataFormat.isDate(value)
returns false for the given value, I think it returned true in the prior version (could be wrong).
Regards,
PaulHi Paul,
The function is not changed. In addition, I don’t suggest you to use internal API.The columns don’t have CellsFormat property. They have cellsformat and this is not the way to set a property of a column.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Thanks for the reply Peter.
column.CellsFormat isn’t a jqxwidgets object, it’s one internal to my app, but it has the same string values as column.cellsformat, sorry for any confusion.
Okay, I didn’t realize $.jqx.dataFormat.isDate was internal, I found it in another post about formatting data just assumed it was accessible. I’ll figure out another way to do this.
Regards,
PaulOkay, figured out the problem, not a jQXWidgets issue per say but will include my solution here for completeness.
My application is based on .NET MVC. By default the JsonResult returns “/Date(123495)/” as the Json date format. This started to become an issue in my application because prior the Json was being returned through SignalR which uses Newtonsoft.Json, which used the default date format of ISO 8601. The solution for my application was to swap out the default JsonResult handler to use Newtonsoft.Json as per the “JsonHandlerAttribute” suggestion in this stackoverflow post.
Hi Paul,
Yes, using Newtonsoft JSON for .NET is a good solution having in mind its built in the new ASP .NET Core.
Best Regards,
Peter Stoev
jQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.