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

Mysql, DateTime and DataSourceResult

2 Answers 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Emmanuel
Top achievements
Rank 1
Emmanuel asked on 20 Apr 2017, 08:39 AM

Hi,

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');
}
else
{
    $input_parameters [] = $model->$property;
}

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 24 Apr 2017, 06:08 AM
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');
$orderDateField->type('date')

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:

$transport->read($read)
          ->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.

Regards,
Stefan
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 (charts) and form elements.
0
Emmanuel
Top achievements
Rank 1
answered on 26 Apr 2017, 04:21 PM

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.

Tags
Grid
Asked by
Emmanuel
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Emmanuel
Top achievements
Rank 1
Share this question
or