Checkbox issue

4 posts, 0 answers
  1. AP
    AP avatar
    241 posts
    Member since:
    Apr 2010

    Posted 21 Oct 2018 Link to this post

    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.

  2. Angel Petrov
    Admin
    Angel Petrov avatar
    1102 posts

    Posted 23 Oct 2018 Link to this post

    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.
  3. AP
    AP avatar
    241 posts
    Member since:
    Apr 2010

    Posted 24 Oct 2018 in reply to Angel Petrov Link to this post

    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?

  4. Angel Petrov
    Admin
    Angel Petrov avatar
    1102 posts

    Posted 25 Oct 2018 Link to this post

    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.
Back to Top