Hi,i am facing an issue while disabling the uncheck of checkbox.want to not allow uncheck checkbox on table through scripting. Screenshot is attached for reference. Does anybody having an idea about it
The Table itself has no way to limit checkboxes in such a way that they only allow clicks to swap to an active state. For that kind of specialized logic you will need to render the column as a View and build your own view to use the only-on logic.
Allow to select columns and rows and then you can use this in the “onSelectionChange”
This should get you started i guess
(im using a json rn, a dataset will be a little different to get the value)
Ofc you probably will have to add in to write to the db or tag where you got it from
if event.selectedColumn == 'isActive': self.props.data[event.selectedRow]['isActive'] = not self.props.data[event.selectedRow] ['isActive']
I would expect that not to work at all because selectedColumn is returning the “name” of the column.
Edit: This reply was rushed. Please see a more thorough explanation below.
The code above works for me
one click on the column:
and again a click:
Sorry, that reply was rushed. What I meant to bring attention to was that the approach is not sufficient.
You are correctly applying logic based on the column name, but that logic is neither sufficient nor in the correct location.
- The original poster only wants to allow for setting a checkbox to an active or
Truestate; your code is changing the state regardless of the previous value and so is not any different than if no logic was applied at all. For example: if the checkbox is already
True, your code will just change it to
- Your code was supplied in the
onSelectionChangeEvent, which will execute whenever a user clicks a cell which was not already selected. The code should be moved to the
onCellEditCommitEvent, which will require the code to be changed because the event has different keys available.
onEditCellCommit Event seems to be able to manage the checkboxes as desired with the following code, where my column name happens to be “Boolean”.
if event.colum == "Boolean": if self.props.data[event.row][event.column] == False: self.props.data[event.row][event.column] = True
if event.column == "Boolean": *****
Ah yes i just allowed to also return it to False, my bad.
But i do not like the onEditCellCommit for a simple boolean, because it requires more clicks instead of just one. (one or two to enter edit and one to check the box)
I guess it just a personal prefference tho
Thank you all for your help and suggestion but the code didn’t work for me.no worries i have added some work around for this issue. Thanks again.
agree same issue i am also facing. it requires more clicks to select.
This is why I recommend supplying your own view to handle editable data.