Autocomplete dataInit

天大地大妈咪最大 提交于 2019-12-25 03:58:30

问题


I'm trying to use jQuery UI Autocomplete inside a jqGrid in the dataInit. I'm doing it like this:

{ name:'ac_fin_g', index:'ac_fin_g', width:75, editable: true, edittype: 'text',
    editoptions: {
        dataInit: function (elem) {
            $(elem).autocomplete({
                source: 'autocomplete.php',
                select: function (event, ui) {
                    #('ac_fin_g').val(ui.item.value);
                }
            });
        }
   }}

And in the function ondblClickRow I'm passing select like a parameter:

ondblClickRow: function (id, select) {
    if (id) {
        if (id !== lastSel) {
            $('#list').restoreRow (lastSel);
            $('#list').editRow (id, true, select);
            lastSel = id;
        } else {
            $('#list').restoreRow (lastSel);
            lastSel = "";
        }
    }
}

This is working but just for the first row.


回答1:


I think that the main reason of your problem is wrong usage of ondblClickRow callback. The second parameter of ondblClickRow callback is the index of the row in the grid. There are other option which you can use. The most full prototype of ondblClickRow callback contains 4 parameters:

// one can use ondblClickRow: function (id) { below because iRow, iCol, e are not used
ondblClickRow: function (id, iRow, iCol, e) {
    var $self = $(this);
    if (id !== lastSel) {
        $self.jqGrid("restoreRow", lastSel);
        lastSel = id;
    }
    $self.jqGrid("editRow", id, true);
}

The third parameter of editRow is oneditfunc callback. The usage of iRow number as oneditfunc callback is wrong.



来源:https://stackoverflow.com/questions/15433876/autocomplete-datainit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!