Skip to content Skip to sidebar Skip to footer

JqGrid - Select Selected Cell's Text While Inline Editing

Part 1) In my grid, I have some editable columns which I would like to do inline editing to. However when I select any particular cell and if the inline editing is available on tha

Solution 1:

I'm not sure about all versions of old web browsers, but you can modify the code of onSelectRow to the following

onSelectRow: function (id) {
    var $self = $(this);
    if (id && id !== lastsel2) {
        $self.jqGrid('restoreRow', lastsel2);
        $self.jqGrid('editRow', id, {
            keys: true,
            focusField: 'Quantity',
            oneditfunc: function (rowid, options) {
                $control = $("#" + rowid + "_Quantity");
                if ($control.length > 0) {
                    $control[0].select();
                }
            },
            aftersavefunc: reload
        });
        lastsel2 = id;
    }
}

see http://jsfiddle.net/OlegKi/HJema/163/. It uses focusField: 'Quantity' option to set the focus on the 'Quantity' column. It uses select() method to select the text of <input> field.

The second part of your question (about bindKeys) seems to me a separate question. The method bindKeys allows to implement custom callbacks onLeftKey, onRightKey. Which one you would like better to use is not full clear for me.


Post a Comment for "JqGrid - Select Selected Cell's Text While Inline Editing"