How to set focus on cell after user Add new row? I tried this:
$(document).delegate("#MyGrid", "iggridupdatingeditrowstarted", function (evt, ui) { var editor = ui.owner.editorForKey("ProductName"); $(editor).igEditor("setFocus", true); $(editor).igEditor("select");}
But focus is still in the first cell of row.
Hello Luis,
Thank you for posting in the community.
A possible way to force focus on any particular input in the adding row would be to handle, as you assumed, EditRowStarted event and get the first editor using jQuery.
Then you can hook the focus event on the first editor and in the event handler force the focus on the any editor that you would like.
For example:
$(document).delegate("#grid", "iggridupdatingeditrowstarted", function (evt, ui) { if(ui.rowAdding) { var row = $("tr[data-new-row='true']"); var firstCell = row.find("span")[0]; $(document).delegate(firstCell, "igeditorfocus", function (evt) { var secondCell = row.find("span")[4]; $(secondCell).igEditor("setFocus", true); $(secondCell).igEditor("select"); }); } });
$(document).delegate("#grid", "iggridupdatingeditrowstarted", function (evt, ui) {
if(ui.rowAdding)
{
var row = $("tr[data-new-row='true']");
var firstCell = row.find("span")[0];
$(document).delegate(firstCell, "igeditorfocus", function (evt) {
var secondCell = row.find("span")[4];
$(secondCell).igEditor("setFocus", true);
$(secondCell).igEditor("select");
});
}
I made a small sample and I am attaching it for your reference.
Please let me know if you need any further assistance with this matter.
Hi Vasya, this code doesn't allow to change focus manually, so users can't move to other cells and I see that igeditorfocus runs many times. :(