【问题标题】:Something like setCell for form edit in JqGrid在 JqGrid 中用于表单编辑的 setCell 之类的东西
【发布时间】:2011-12-21 22:52:48
【问题描述】:

好的,我一直在 @Oleg 的很多答案中寻找答案,但我找不到任何东西。我有这个网格,可以在其中在线编辑,在某些字段中,我正在使用自动完成功能,当我选择某些项目时,我使用 setCell 将值写入另一个字段。我的列模型是这样的......

{ name: 'Label', index: 'Label', width: 100, align: 'Center', sorttype: "string",
    editable: true, editrules: { required: true },
    editoptions: {
        dataInit: function (elem) {
            $(elem).autocomplete({
                autoFocus: true,
                source: function (request, response) {
                    PageMethods.ObtLabels(request.term, function (data) {
                        var tiposCliente = (typeof data) == 'string' ?
                                           eval('(' + data + ')') : data;
                        response(tiposCliente);
                    }, fnLlamadaError);
                },
                minLength: 1,
                select: function (event, ui) {
                    var rowid = $('#pendientes').getGridParam('selrow');
                    **jQuery('#pendientes').setCell(rowid, 'LabelId', ui.item.id);**
                }
            });
        }
    }
},

这在编辑和添加内联时工作正常,但是当我想使用表单添加或编辑一行时,我无法在另一个字段中写入值。

我不知道我的问题是否清楚。我只想在“X”字段中写一些东西,这取决于我在“Y”字段中选择的选项。所有这些都使用表单。

如果有人可以帮助我,那就太好了。

非常感谢!

更新和解决方案:

我只是在我的代码中添加下一行:

$('input#LabelId').val(ui.item.id);

及其工作,我在 LAbelId 中写入所选项目的值

最后,我的带有自动完成功能的专栏的 el 代码是这样的:

{ name: 'Label', index: 'Label', width: 100, align: 'Center', sorttype: "string",
    editable: true, editrules: { required: true },
    editoptions: {
        dataInit: function (elem) {
            $(elem).autocomplete({
                autoFocus: true,
                source: function (request, response) {
                    PageMethods.ObtLabels(request.term, function (data) {
                        var tiposCliente = (typeof data) == 'string' ?
                                           eval('(' + data + ')') : data;
                        response(tiposCliente);
                    }, fnLlamadaError);
                },
                minLength: 1,
                select: function (event, ui) {
                    var rowid = $('#pendientes').getGridParam('selrow');
                    jQuery('#pendientes').setCell(rowid, 'LabelId', ui.item.id);
                    **$('input#LabelId').val(ui.item.id);**
                }
            });
        }
    }
},

【问题讨论】:

  • 我不清楚'LabelId' 列是否可编辑?你使用multiselect: true的单选模式吗?
  • 是的 LabelId 是可编辑的,它也被隐藏了......但我已经找到了答案,我只是添加了这一行...... $('input#LabelId').val(ui .item.id);以及它的工作,我在 LABelId 中写入所选项目的值......非常感谢!求答案

标签: javascript jquery asp.net jqgrid


【解决方案1】:

好的,我找到了答案,我只是添加下一行...

$('input#ClienteProveedor').val(ui.item.id);

这会将 ui.item.id 写入我想要的“Y”字段。

【讨论】:

    猜你喜欢
    • 2011-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-05
    • 2012-06-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多