Checkbox column - Checkboxes persist checked state

2 posts, 0 answers
  1. Justin Lee
    Justin Lee avatar
    176 posts
    Member since:
    Dec 2009

    Posted 05 Mar 2019 Link to this post

    Hello,

    I have added a checkbox column as per the suggestion here:

    https://www.telerik.com/forums/treelist-with-checkboxes

    The main difference is I am not binding the checkboxes' values, and I reload the list at times.

    The issue is if I check the box in any row - for example: Row 1,  then I reload the grid (with different data) - the checkbox in row 1 will still be checked, even though the list has been reloaded (grid.dataSource.read()) and populated with different data.

    It is very odd behavior - is there any fix or workaround?

    I created a dojo reproducing the behavior.

    http://dojo.telerik.com/ehIwuKOS

    1. Check the box in Row 1  (or Row 2, it doesn't matter)

    2. Click the "Reload Grid" button to reload the list's data.

    3. Note that the checkbox is still checked.

     

    Thanks,

    Justin

  2. Stamo Gochev
    Admin
    Stamo Gochev avatar
    216 posts

    Posted 07 Mar 2019 Link to this post

    Hi,

    The observed behavior is because the TreeList uses virtual dom diffing, which detects changes in attributes, but not props. This is basically a limitation of the rendering, so what I can  recommend is to manually reset the state on the "dataBound" event:

    https://dojo.telerik.com/aqexivoJ

    dataBound: function(e) {
        var treelist = e.sender;
        treelist.wrapper.find("[type='checkbox']").prop("checked", false);
    }


    Regards,
    Stamo Gochev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top