Reputation: 2929
There are many questions about focus()
however I could not find any working solution for my problem.
I am using Slick Grid with some columns:
{id: "Something", name: "Something", field: "Something", width: 200, editor: Slick.Editors.Text }
var ResourcesGridOptions = {
editable: true,
enableCellNavigation: true,
enableColumnReorder: false,
autoEdit: false
};
I implemented a button to create new rows. Now I would like to automatically focus the input text. At this point I am able to set the mode "edit" on, but the focus()
does not work.
Perhaps someone could help me out.
In Chrome Javascript console I am using:
$($('.slick-cell:eq(2)').dblclick().find('input')[0]).select().val("").focus()
And the console returns:
[<input type="text" class="editor-text" value="">]
Update 1
I've tried to add an "Id" to this input field and then focus it directly.... didn't work.
$($('.slick-cell:eq(2)').dblclick().find('input')[0]).attr('id', 'Something')
$('#Something').focus()
Returns: [<input type="text" class="editor-text" value="" id="Something">]
Upvotes: 1
Views: 685
Reputation: 4298
Try calling following function on Click event of add button,
function AddNewRow() {
var dataLength = dataView.getLength();
//dataView.addItem({ "Id": -1 });
//dataView.refresh();
grid.gotoCell(dataLength, 0, true);
}
Upvotes: 2