buri kuri
buri kuri

Reputation: 429

How to lose focus on a cell in SlickGrid

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.

Upvotes: 1

Views: 2948

Answers (3)

Jatin patil
Jatin patil

Reputation: 4298

You can achieve it as follows,


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

Upvotes: 0

Tin
Tin

Reputation: 9082

Try calling grid.resetActiveCell().

Upvotes: 1

idbehold
idbehold

Reputation: 17168

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.

Upvotes: 0

Related Questions