自动完成数据初始化 [英] Autocomplete dataInit

查看:114
本文介绍了自动完成数据初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在dataInit的jqGrid中使用jQuery UI Autocomplete.我正在这样做:

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

在函数ondblClickRow中,我像参数一样传递select:

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.

推荐答案

我认为问题的主要原因是ondblClickRow回调的用法不正确. ondblClickRow回调的第二个参数是网格中行的索引.您还可以使用其他选项. ondblClickRow回调的最完整原型包含4个参数:

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

editRow 的第三个参数是回调.将iRow数字用作oneditfunc回调是错误的.

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

这篇关于自动完成数据初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆