on rearranging a column in the grid, it looses the focus
When moving the column or say rearranging a column by drag and drop, grid looses the focus. Is there a way to address this?
Seems rather normal to me, I mean if you reordering a column then your focus is now on the column header. However, what is possible to do is to use some of the Grid Events like onDragEnd to call a focus (by focusing back on the Grid DOM element) when your drag is over which is possibly what you want to do.
Seems rather normal to me, I mean if you reordering a column then your focus is now on the column header. However, what is possible to do is to use some of the Grid Events like
onDragEndto call a focus (by focusing back on the Grid DOM element) when your drag is over which is possibly what you want to do.
The focus is not even on the header column. I am forcing the focus back to the grid after the drag is complete. I was hoping if there was a better way to address this. For now this work around works for me
I'm not sure what you mean by forcing the focus back to the grid? Where exactly are you trying to focus?
I'm not sure what you mean by forcing the focus back to the grid? Where exactly are you trying to focus?
I am trying to bring the focus back to the grid the way you stated using the onDragEnd event using grid.focus(). But that didnot work. So I had to focus on to the one of the element in the grid.
Why would grid.focus() doesnot work?
Yes I realized that I give you false information about the onDragEnd, it's not the good event to use. I see in the slick.grid.js that there is indeed a focus() function but I can't really help you on that, I never tried it and you say it doesn't work. But again, I still don't understand where exactly you want to set the focus to, are you trying to focus on the last cell you were before the dragging event occurred? Just focusing on the grid, is rather vague, what benefit would you have in just focus on the grid?
Yes I realized that I give you false information about the
onDragEnd, it's not the good event to use. I see in theslick.grid.jsthat there is indeed afocus()function but I can't really help you on that, I never tried it and you say it doesn't work. But again, I still don't understand where exactly you want to set the focus to, are you trying to focus on the last cell you were before the dragging event occurred? Just focusing on the grid, is rather vague, what benefit would you have in just focus on the grid?
I should have been more clear, when i say focus n grid, i mean focus on last active cell.
If I look at the code, I see that there's maybe the trigger onActiveCellChanged that you could use, to keep the last active cell node (which I think is the node of DOM element). With that, you can try to save a reference of the last active node, then re-focus on it whenever you need to with node.focus() or node[0].focus() with jquery. However that might not be what you want, you might want to tell SlickGrid that you are changing focus on a new active cell, in that case I guess you will need to try setActiveCell, but I'm not sure exactly which arguments you really need for it to work, the signature is
function setActiveCell(row, cell, opt_editMode, preClickModeOn, suppressActiveCellChangedEvent) { }
I assume you will need the first 2 arguments, which I believe are row index and cell index (or column index). I don't think the other arguments are mandatory.
Note that I did not test anything, but I believe you might be able to get something working out of that.
@codeme : I tried it out and what I can reproduce is that if the cell is editale and the column gets dragged around the grid loses the focus as you describe. If the cell is not editable I do not see this issue. The focus is not dragged around but stays at the given position. Meaning if it was on row 2 column 2 and I drag the column 2 to column 3 the focus stays on row 2 colmn 2. Do you see the same?