Hey Karl,Thanks for pointing me to the problem – I really missed the application of the igFormatter in my updated sample.You are also correct in your assessment of the ig Templating Engine: it doesn’t support functions due to performance reasons. I believe that this is stated in somewhere the help documentation as well.So the problem indeed becomes tricky as hell, so the solution I can give is to use a workaround.Instead of applying the date formatting functions in the itemTemplate, simply have the date values formatted before they are displayed.This means modifying the date values of the date property from the source data (in the igCombo’s dataBound event).Here’s the code I’m using:
$('#comboIG').igCombo({
filterExprUrlKey: null,
filteringType: 'local',
renderMatchItems: 'contains',
responseDataKey: 'd.results',
//valueKey: 'Name',
valueKey: 'LastName',
width: '300px', //itemTemplate: "<div class=\'comboItemContainer\'><div class=\'empInfo\'><span class=\'empName\'>${Name}</span><p>${BirthDate}</p></div></div>", itemTemplate: "<div class=\'comboItemContainer\'><div class=\'empInfo\'><span class=\'empName\'>${FirstName} ${LastName}</span><p>${BirthDate}</p></div></div>", inputName: 'comboIG',
//dataSource: 'http://labs.infragistics.com/igniteui/api/employees?callback=?', // OData v.3
dataSource: 'http://services.odata.org/Northwind/Northwind.svc/Employees?$format=json&$callback=?', // OData v.1 or v.2
dataBound: function(evt, ui) {
var comboData = ui.dataSource.data();
for(var i = 0, len = comboData.length; i < len; i++)
{
comboData[i]["BirthDateOriginal"] = comboData[i]["BirthDate"];
// Use in case your dates are returned by an ASP.NET JSON serializer. Comment the line below if you use the Infragistics Northwind OData service.
comboData[i]["BirthDate"] = igFormatter(parseToDate(comboData[i]["BirthDate"]), 'date', 'dateTime');
}
}
});
Some explanations are in order:
The official NorthWind OData service still uses the v.2 URI conventions and the default ASP.NET JSON serializer so the dates it serves are still in the format “\/Date(milliseconds)\/”. This is where the igFormatter and the parseTodate functions can be used in order to get the desired formatting.However, our Samples Browser’s Northwind OData service is actually ASP.NET WebAPI with OData attributes and so it adheres to version 3 of the OData standard and it uses the NewtonSoft JSON serializer. This combination of facts means that dates are served in the “dd/MM/YYYY” format which doesn’t require formatting (unless you wish to format your date in a different format).This is why I’ve commented out 3 lines of the code above – you can uncomment them and switch to our Samples Browser’s OData service to see the differences.
Regardless of the used OData service used, I think it’s a good practice to have the original value of the date property just in case. This is why I’m backing each of those values in the BirthDateOriginal property.PS: Sorry for the temporary awful formatting of the sample code – the forum wanted to play a trick on me with that one.Hope this helps.-Bobby