Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2165
Set cell focus
posted

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.

Parents
No Data
Reply
  • 17590
    Offline posted

    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");

    });

    }

    });

    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.

    gridRowAdding.zip
Children