Reputation: 936
I would like to display both description and Date in my kendo auto complete. THe following code will display as expected except the date. The date is displaying weird format
xml:
<d:SDate m:type="Edm.DateTime">2012-11-21T18:30:51.097</d:SDate>
if i type Nike it will come up Nike (/Date(13534560000)/)
$("#titles").kendoAutoComplete({ minLength: 3, dataTextField: "SDesc", dataValueField: "RefID", template: '${ data.SDesc } ' + '(' + '${ data.SDate }' + ')',
dataSource: {
type: "odata",
serverFiltering: true,
serverPaging: true,
pageSize: 20,
transport: {
read: "http://localhost:54329/HH_WcfDataService.svc/Product"
}
}
});
Upvotes: 2
Views: 338
Reputation: 30671
You can try using kendo.parseDate in your template:
template: '${ data.SDesc } ' + '(' + '${ kendo.parseDate(data.SDate) }' + ')',
Here is a live demo: http://jsbin.com/ekogex/1/edit
Upvotes: 0
Reputation: 40897
You are getting the weird date format because the Date
is actually stored as a number. You need to format it to your desired format yyyy-mm-dd
, mm-dd-yyyy
, dd-mm-yyyy
,... Try using kendo.format
and/or kendo.toString
(check http://docs.kendoui.com/getting-started/framework/globalization/dateformatting for information on displaying dates in your local/desired format).
I think that kendo.toString
will work for you since it accepts a number
as argument for dates (http://docs.kendoui.com/api/framework/kendo#tostring)
Upvotes: 1