2011-12-21 47 views
1

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

{ 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”字段中选择的opcion。所有这些使用表单。

如果有人能帮助我,那会很棒。

非常感谢!

更新及解决方法:

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

$( '#输入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);** 
       } 
      }); 
     } 
    } 
}, 
+0

目前还不清楚“LabelId”列是否可编辑?你使用'multiselect:true'单选模式吗? – Oleg 2011-12-22 12:23:35

+0

是LabelId是可编辑的,它也被隐藏了......但我已经找到了答案,我只是在这一行中添加了这个.... $('input#LabelId').val(ui.item.id) ; 和它的工作,我写在LAbelId所选项目的价值... 非常感谢!为了回答 – MaikaDalila 2011-12-22 12:44:00

回答

0

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

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

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