Automatically uncheck checked checkbox after list of options


Topic: Automatically uncheck checked checkbox after list of options is updated

Torroni pro asked a year ago

Expected behavior If a checkbox column is added to a datatables control, more often than not is because some action needs to be performed on the selected rows. If the action changes the contents of the rows (e.g. delete the corresponding entries in a backend database), and the update method is called to refresh the contents of the datatables, the status of all checkboxes should be reset to "not checked", because the same rows now contain different data: if rows 3 and 4 were selected before the update, it does not make sense that rows 3 and 4 continue to be selected after the update, because if the update method has been called, it is because the contents have to be updated and it does not make sense to make the assumption that rows 3 and 4 are the only ones that have not been updated and therefore must continue to be selected. The same applies to a select control: if options 3 and 4 are selected, and the list of options is updated, it does not make sense for the "new" options 3 and 4 to be selected.

Actual behavior In a datatables control with a checkbox column, once a set of rows is selected (i.e. the checkboxes are checked), they remain selected even after the table is updated. The same happens to the checkboxes in a select control.

Resources (screenshots, code snippets etc.)


Kamila Pieńkowska staff answered a year ago

I'm sorry but what is expected or desired is not necessarily the same for all users. The behavior you expect is possible to achieve with some added JS.

If we change it other users would have to change the code of the actual package to keep current behavior.


Torroni pro answered a year ago

"some added JS" is a nuisance, because one must do 2 separate things:

  • set the checked attribute to false for the input element
  • remove the "active" class from the row element

Maybe you could provide a method for programmatically checking and un-checking a checkbox.


Grzegorz Bujański staff commented a year ago

We will consider it.


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: -
  • Device:
  • Browser:
  • OS:
  • Provided sample code: No
  • Provided link: No