This is a migrated thread and some comments may be shown as answers.
Checkbox column - Checkboxes persist checked state
1 Answer 68 Views
This is a migrated thread and some comments may be shown as answers.
Justin Lee
Top achievements
Rank 1
Justin Lee asked on 05 Mar 2019, 07:05 PM

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

1 Answer, 1 is accepted

Sort by
0
Stamo Gochev
Telerik team
answered on 07 Mar 2019, 10:53 AM
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.
Asked by
Justin Lee
Top achievements
Rank 1
Answers by
Stamo Gochev
Telerik team
Share this question
or