Reputation: 4063
How do we control the format of date sent to the server as a result of applying a Date Filter to a grid column. For example, I have following View
<script type="text/javascript">
$("#request-grid").kendoGrid({
dataSource: {
...
schema: {
model: {
fields: {
CreatedOn: { type: "date" },
...
}
}
}
},
columns: [{
field: "Id", title: "Id", width: 20
}, {
field: "CreatedOn", title: "Created On", width: 75, format: "{0:dd-MM-yyyy}"
}, {
command: ["edit", "destroy"], width: 200
}],
});
</script>
With when I try to filter the Date Column (CreatedOn), I see that the parameter is sent in format
Wed Mar 12 2014 00:00:00 GMT+0530 (India Standard Time).
How do I control the format of date that is being sent to server as a result of applying a Date filter on grid column.
I have already followed the procedure of setting culture as described here. Here is how I configured in the Layout page.
kendo.timezones.js and kendo.culture.en-IN.js included through bundle
<script type="text/javascript">
kendo.culture("en-IN");
</script>
Any advice please.
Upvotes: 3
Views: 3784
Reputation: 162
I was recently fighting the same issue and for me the simplest way was to override the Date object toString method. I did it this way:
Date.prototype.toString = function() {
return this.getFullYear() + "-" + (this.getMonth() + 1) + "-" + this.getDate() + " " + this.getHours() + ":" + this.getMinutes() + ":" + this.getSeconds();
}
Upvotes: 1
Reputation: 20203
if chaging the culture is not doing the work. Then the function that you need to use is called parameterMap under the dataSource.transport configuration.
Upvotes: 2