When I create a checkbox column (through use of formatters/editors) in Slickgrid, I've noticed that it takes two clicks to interact with it (one to focus the cell, and one to interact with the checkbox). (Which makes perfect sense)
However, I've noticed that I am able to interact with the checkbox selectors plugin (for selecting multiple rows) with one click. Is there any way I can make ALL of my checkboxes behave this way?
For futher readers I solved this problem by modifing the grid data itself on click event. Setting boolean value to opposite and then the formatter will display clicked or unclicked checkbox.
Hope it helps.
Register a handler for the "onClick" event and make the changes to the data there. See http://mleibman.github.com/SlickGrid/examples/example7-events.html
I used the
onBeforeEditCell
event to achieve this for my boolean field 'can_transmit'Basically capture an edit cell click on the column you want, make the change yourself, then return false to stop the cell edit event.
This works for me. However, if you're using the DataView feature (e.g. filtering), there's additional work to update the dataview with this change. I haven't figured out how to do that yet...
The only way I found solving it is by editing the
slick.checkboxselectcolumn.js
plugin. I liked the subscribe method, but it haven't attached to me any listener to the radio buttons.So what I did is to edit the functions handleClick(e, args) & handleHeaderClick(e, args). I added function calls, and in my js file I just did what I wanted with it.
Code
pastebin.com/22snHdrw
Search for my username in the comments
I managed to get a single click editor working rather hackishly with DataView by calling
in my CheckBoxCellEditor function, and calling Slick.GlobalEditorLock.commitCurrentEdit(); when the CheckBoxCellEditor created checkbox is clicked (by that setTimeout).
The problem is that the CheckBoxCellFormatter checkbox is clicked, then that event spawns the CheckBoxCellEditor code, which replaces the checkbox with a new one. If you simply call jquery's .click() on that selector, you'll fire the CheckBoxCellEditor event again due because slickgrid hasn't unbound the handler that got you there in the first place. The setTimeout fires the click after that handler is removed (I was worried about timing issues, but I was unable to produce any in any browser).
Sorry I couldn't provide any example code, the code I have is to implementation specific to be useful as a general solution.
The way I have done it is pretty straight forward.
First step is you have to disable the editor handler for your checkbox. In my project it looks something like this. I have a slickgridhelper.js to register plugins and work with them.
Next step is to register an onClick event handler in your custom js page which you are developing.
Now a single click is suffice to change the value of your checkbox and persist it.