【问题标题】:jqGrid Change the value of a field on beforeShowFormjqGrid 更改 beforeShowForm 上某个字段的值
【发布时间】:2015-08-17 18:22:16
【问题描述】:

我有一个在预定义字段中有值的网格,我想做的是单击编辑一行想要更改 FormEdit 中某个字段的值。

ColModel 是:

    colModel:[
                {name:'id',index:'ID', width:50, hidden:true, search:false, editable:false,resizable:false},
                {name:'product',index:'product', align:"center", width:20, search:false, editable:false,resizable:false},
                {name:'volume',index:'volume', align:"center", hidden:false, width:15, search:false, editable:true}
                ],

我会在打开编辑表单时设置音量 = 1,我确实喜欢这样......

 ondblClickRow: function(id){
                jQuery("#products").jqGrid('editGridRow', id, {
                  recreateForm:true,  
                  beforeShowForm: function(form) { 
                      $('#tr_volume',form).show(); 
                      $("#tr_volume",form).val('1');
                      },
                  reloadAfterSubmit:false, closeOnEscape:true, closeAfterAdd:true, closeAfterEdit:true,
                  editable:true, editrules:{edithidden:true,required:true,number:true,minValue:1}                    
               })

但这对我不起作用,怎么了?

【问题讨论】:

    标签: jquery jqgrid jqgrid-php


    【解决方案1】:

    您不使用 volume 列的 hidden: true 属性。所以不需要设置$('#tr_volume',form).show()$("#tr_volume",form).val('1') 的设置是错误的,因为<tr> 元素没有值。我认为你需要 jusu 使用 $("#volume",form).val('1')$("#volume").val('1') 代替。将在表单中创建带有 id="volume"<input> 字段(与列名相同的 id)。这是您可能尝试更改的领域。

    【讨论】:

    • @Sici:不客气!如果问题得到解决,您应该"accept" 回答并获得您的第一个声誉积分。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-25
    • 1970-01-01
    • 2021-12-20
    • 1970-01-01
    相关资源
    最近更新 更多