How to lose focus on a cell in SlickGrid

2019-07-27 06:27发布

My question is exactly opposite of this question. So what I'm trying is I'm trying to find a way to lose focus on a cell after user selects an item from the autocomplete combobox in that cell.

 $input.autocomplete({
                delay: 0,
                minLength: 0, 
                source: args.column.options,
                select: function (event, ui) {
                    $input.val(ui.item.label);
                   grid.getEditController().commitCurrentEdit();
              return false;
                }
            });

I used this code to lose focus indirectly after finishing with editing. It works fine, however, the cell stays selected somehow.

grid.getEditController().commitCurrentEdit();

I also tried the code below to lose focus but it throws error everytime when I run the code.

grid.setActiveCell();
grid.setSelectedRows(-1);

After selecting an item from the autocomplete combobox, I want the grid to lose focus and select nothing on the viewport of the grid.

Thanks for your answers in advance.

3条回答
Deceive 欺骗
2楼-- · 2019-07-27 06:41

You can achieve it as follows,


            if (grid.getActiveCell()) {
            var row = grid.getActiveCell().row;
            var cell = grid.getActiveCell().cell;
            grid.gotoCell(row, cell, false);
        }

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-07-27 06:48

Try calling grid.resetActiveCell().

查看更多
4楼-- · 2019-07-27 06:48

There was a commit made to the master branch last week that might address your issue: Fix keyboard focus getting trapped when cell has tabbable elements.

查看更多
登录 后发表回答