Slickgrid - One-click checkboxes?

前端 未结 6 2151
慢半拍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:03

    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.

    function handleClick(e, args) {
        if (_grid.getColumns()[args.cell].id === _options.columnId && $(e.target).is(":checkbox")) {
            ......
            //my custom line
            callCustonCheckboxListener();
            ......
        }
    }
    

    function handleHeaderClick(e, args) {
        if (args.column.id == _options.columnId && $(e.target).is(":checkbox")) {
            ...
            var isETargetChecked = $(e.target).is(":checked");
            if (isETargetChecked) {
                ...
                callCustonHeaderToggler(isETargetChecked);
            } else {
                ...
                callCustonHeaderToggler(isETargetChecked);
            }
            ...
        }
    }
    

    Code

    pastebin.com/22snHdrw

    Search for my username in the comments

提交回复
热议问题