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

Checkbox issue

3 Answers 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AP
Top achievements
Rank 1
Iron
Iron
Veteran
AP asked on 21 Oct 2018, 11:50 AM

I have a strange issue. I have a grid, with a pop-up editor template, with a boolean field.

This has been working fine until recently, when (I assume after an update to PHP or the MariaDB backend) inserting new records now fails when the checkbox is left unchecked.

After a lot of searching, I found the error message being returned through JSON.

 

It is {"errors":["Incorrect integer value: '' for column 'Read' at row 1"]} . It seems the grid is passing '' instead of 0, for a false value.

If the checkbox is ticked, a new record is inserted without a problem. The issue also affects updates, the checkbox can be ticked, but not unchecked.

The field is defined as a boolean in the model definition:-

$readField = new \Kendo\Data\DataSourceSchemaModelField('Read');
   $readField->type('boolean');

 

And the checkbox is defined as :-

<p><label>Read?:</label><input type="checkbox" name="Read" data-bind="value:Read" > </p>

In the editor template definition

I have tried updating to the latest version of KendoUI, but the problem still persists

The field is a type TinyInt in the database, and is non nullable.

3 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 23 Oct 2018, 02:10 PM
Hello,

Actually the grid should pass a boolean value for the mentioned field. Was the field type changed when updating the backend? If so you may need to subscribe to the parameterMap as shown here and modify the parameters which are sent to the backend. The idea is to correct the value based on the desired type and current value.

Regards,
Angel Petrov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
AP
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 24 Oct 2018, 10:00 AM

No schema changes have been made to the database, I'm at a loss as to why it now doesn't work - unfortunately updates and inserts aren't done regularly, so I can't identify exactly what's changed since it last worked (it just wasn't the code or schema). I'm assuming either a database (MariaDB) or PHP (7) update is to blame.

My code matches the example you gave, but I haven't got a parameter map. The example for this you gave shows how to configure this in JavaScript. However, I'm doing this using the PHP wrappers - can I have an example of defining a parameter map using the PHP wrappers please?

0
Angel Petrov
Telerik team
answered on 25 Oct 2018, 02:44 PM
Hello,

The parameterMap is a client-side option meaning that JavaScript will be required. However when using the wrappers attaching this option is possible as demonstrated in the linked demo.

$transport->create($create)
          ->read($read)
          ->update($update)
          ->destroy($destroy)
          ->parameterMap('function(data) {
              return kendo.stringify(data);
          }');

In the above code the JavaScript function will be called when a request to the service is made.


Regards,
Angel Petrov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
AP
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Angel Petrov
Telerik team
AP
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or