Hello.
I would like to add an element to my datatable (connected to database with php connector) with one of the field as NULL.
I tried the following:
datatable.add({…, field: null, …});
datatable.add({…, field: ‘null’, …});
datatable.add({…, field: ‘’, …});
datatable.add({…, …}); (not specifying the field, default value in database configuration being NULL)
I always get a value of ‘0’ for the field when reloading the datatable.
Kind regards,
Pierre
I think I found a solution. If my understanding is correct, the problem comes from the connector as it will consider the absence of the field as value “” (empty string). The following modifications to my connector seems to handle the issue:
<code class="js">function validate_field($action){
if ($action->get_value("field") == "")
{
$action->set_value("field", NULL) ;
}
}
$data->event->attach("beforeInsert","validate_field");
$data->event->attach("beforeUpdate","validate_field");`
Please let me know if there was an easier solution.
Kind regards.
maksim
November 25, 2014, 8:46am
3
As far as I can see - the above one is the best solution