0

Currently, the grid is defined as this:

   $('#gridManagers').kendoGrid({
    dataSource: dataSourceManagers,
    columns: [
        { field: 'First', title: 'FirstName' },
        {
            field: 'HireDate', format: "{0:dd-MM-yyyy}", filterable: {
                ui: filterDate
            }
        },
    ],
    filterable: true,
    sortable: {
        mode: 'multiple'
    },
    pageable: true
});

function filterDate(element) {
    element.kendoDatePicker({
        format: 'MM-dd-yyyy',
        close: function (e) {
        console.log("_value:"+this._value);
        this._value = kendo.toString(this.value(), "MM-dd-yyyy");
        console.log("this.value():" + this.value());
    }
});

When I select a date from the DatePicker, the console logging shows this:

LOG: _value:Sat Nov 30 00:00:00 UTC+0100 2013 
LOG: _current:11-14-2013 
LOG: this.value():11-30-2013 

The reason I do the conversion from 'Sat Nov 30 00:00:00 UTC+0100 2013' to '11-30-2013' is because the format is not recognized correctly on the server.

What I don't understand how the value from the DatePicker is retrieved by the grid and used to define the filter ?

Stef Heyenrath
  • 9,335
  • 12
  • 66
  • 121

1 Answers1

0

Do not mess the value of the DatePicker and the Grid when converting it to string, it should be a Date.

If you want to send the value in different format then use the parameterMap function to transform it the way you need it on the server.

Petur Subev
  • 19,983
  • 3
  • 52
  • 68
  • I know this functionality, it can be used to modify filter values. However in order to do this I need to loop ALL filter values and try to convert EVERY value with kendoString to a MM-dd-yyyy string. There is no easy way I can only do the conversion for date values only. (maybe loop all defined columns and match the name to get the data type, 'date'). So I wanted to fix the problem at the root ; the datetimepicker. – Stef Heyenrath Nov 13 '13 at 23:10