This is a migrated thread and some comments may be shown as answers.

Strange behaviour with date column

1 Answer 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bruno
Top achievements
Rank 1
Bruno asked on 04 Apr 2012, 05:35 PM
I have a Grid with a date column. In the datasource's model, it is defined with type='date'.
First problem: the first time the grid is displayed, the date is well displayed. If I edit another column, after saving changes, the date is displayed in json format. If I click "refresh" the date is well displayed again.
Second problem: I can't save the date modifications, it seems the grid doesn't send the value of the grid column.

I've made a screencast that shows that: http://screencast.com/t/jYj97QV1

1 Answer, 1 is accepted

Sort by
0
Daniel
Top achievements
Rank 1
answered on 25 Apr 2012, 09:16 AM
Hi Bruno,

Try using the parameterMap option on the transport setting of the DataSource as shown below.

parameterMap: function(options, operation) {
    if (operation != "read"){
        var d = new Date(options.TaskDate);
        options.TaskDate = kendo.toString(new Date(d), "MM/dd/yyyy");
        //alert("parameterMap TaskDate: " + options.TaskDate);
        return options;
    }
}

The above code assumes your server expects the date format used above.

And for the columns definition, I have this...

columns: [    {field: "TaskDate", title: "Date", width: "60px", template: '#= kendo.toString(TaskDate, "dd/MM/yyyy")#'},
                    {field: "TaskDescription", title: "Task Description", width: "120px"},
                    {field: "Hours", title: "Hours", width: "50px", format: "{0:n0}"},
                    {field: "Minutes", title: "Minutes", width: "50px", format: "{0:n0}"},
                    {command: ["edit", "destroy"], title: " ", width: "140px" }  ]

I still have a problem though.  When I save the changes after adding a new record (or editing a record), the date display is back to the "long" format.  I had to refresh the browser to show the required format.

Cheers,
Dan
Tags
Grid
Asked by
Bruno
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 1
Share this question
or