Slickgrid - One-click checkboxes?

前端 未结 6 2155
慢半拍i
慢半拍i 2021-02-13 13:05

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 i

6条回答
  •  感动是毒
    2021-02-13 14:01

    I managed to get a single click editor working rather hackishly with DataView by calling

    setTimeout(function(){ $("theCheckBox").click(); },0);
    

    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.

提交回复
热议问题