I have a jQuery combobox in which I want to display a name column and a date column.
@(Html
.Infragistics()
.Combo()
.ID("comboEvents")
.FilteringType(ComboFilteringType.None)
.ValueKey("eventId")
.TextKey("name")
.DropDownMinHeight(50)
.Width("300px")
.DataSource(Url.Action("EventListCombo"))
.ItemTemplate("<div>${name} (${date})</div>")
.DataBind()
.Render()
)
Obviously the date shows up as a JSON date ("/Date(1315540800000)/"). How can I get the jQuery date format to work within the above itemtemplate?
This no longer appears to work with the Infragistics templating engine. Is it possible to get an updated sample?
Point taken and correction made ;)
Hi Josh,As psurobdude suggested, you will need to parse the serialized date from the server response.
Just to be clear, psurobdude is looking for the answer, and I made the suggestion :).
psurobdude said:Obviously the date shows up as a JSON date ("/Date(1315540800000)/"). How can I get the jQuery date format to work within the above itemtemplate?
Hi Josh,As JoshNoe suggested, you will need to parse the serialized date from the server response.
What I can recommend is to use a simple function for this task - for example:
var parseToDate = function(val) { return new Date(parseInt(val.replace('/Date(', '').replace(')/', ''), 10));};And if you want to format the dates you have just like the grid does, you will need to do this yourself as we don't provide it as an out of the box.I'm partially lying to you here, because if you dig into the code of the igGrid, you will see that in order to apply column formatting, the igGrid relies on a function called $.ig.formatter() - it's defined in the ig.util.js file and is meant to be internal, but I don't see a reason why you shouldn't use it.Basically the $.ig.formatter() function is easy to use, because all you need is to call it with the first 3 parameters:
I've attached an HTML sample page to this reply which illustrates my suggestion.Hope it helps you out1.Cheers and good luck!Borislav
Correct, no, you can't use the method I linked to directly in IG's itemtemplate. You'd convert the date values in your datasource using javascript, then send your datasource to igcombo with the dates already in an acceptable format.
There may be some way to have IG's datasource recognize JSON dates and display them formatted in the way you like, but it's not immediately apparent to me from looking at their documentation.
http://www.igniteui.com/help/api/2015.2/ig.datasource