Mysql, DateTime and DataSourceResult

3 posts, 0 answers
  1. Emmanuel
    Emmanuel avatar
    7 posts
    Member since:
    Feb 2017

    Posted 20 Apr 2017 Link to this post


    I use the DataSourceResult as the datasource of my grid.

    But DateTime are not inserted/updated correctly as they are not correctly formated for MySql.

    I had to add the following code to the update method. Same code would also be required for insert I think.

    Do you have a better solution than mine ?


    $result = date_parse($model->$property);
    if($result["error_count"] == 0)
        $input_parameters [] = date_format(new DateTime($model->$property), 'Y-m-d H:i:s');
        $input_parameters [] = $model->$property;
  2. Stefan
    Stefan avatar
    2786 posts

    Posted 24 Apr 2017 Link to this post

    Hello Emmanuel,

    First I can suggest ensuring that the type of the column is set to a date in the order to send the value as a valid date object:

    $orderDateField = new \Kendo\Data\DataSourceSchemaModelField('OrderDate');

    Still, if just the format is not the same as the expected one and cannot be parsed, I can suggest using the parameterMap property which will allow modifying the request send to the server:

              ->parameterMap('function(data) {
                  return kendo.stringify(data);

    If both does not help, then the values have to be manually parsed on the server as shown in the question.

    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Emmanuel
    Emmanuel avatar
    7 posts
    Member since:
    Feb 2017

    Posted 26 Apr 2017 Link to this post

    Hi Stéphan,

    Thanks for your help.

    I had to process data on the server side as there was also issues with timezones. So I parsed the data and adjust the timezone within the DataSourceResult class before SQL operations.

Back to Top