代码之家  ›  专栏  ›  技术社区  ›  Bob

内联编辑后的jqgrid setrowdata

  •  0
  • Bob  · 技术社区  · 16 年前

    在内联编辑后更新行时遇到问题。 我的ColModel是:

    colModel: [
        { name: 'Email', index: 'Email', editable: true },
        { name: 'ReferenceEmail', index: 'ReferenceEmail', editable: true },
          // hidden: true, editable: true, editrules: { edithidden: true}
        { name: 'Title', index: 'Title', editable: true, edittype: "select",
          editoptions: { value: "Mr:Mr;Mrs:Mrs;Ms:Ms;Doctor:Doctor;Sir:Sir"} },
        { name: 'Forename', index: 'Forename', editable: true },
        { name: 'Surname', index: 'Surname', editable: true },
        { name: 'Study_Manager', index: 'Study_Manager', editable: true,
          edittype: "select", editoptions: { value: "True:True;False:False"} }
    ]
    

    我计划设置referenceemail col值=新编辑的email值,因此我有:

    ondblClickRow: function (id, ri, ci) {
                lastSelUser = id;
                $("#UserGrid").editRow(id, true, false, reload);
            }
    

    它反过来调用reload onsuccess of the edit,

    function reload(result) {
        var cell = $("#UserGrid").getCell(lastSelUser, 'Email');
        var newEmail = $(cell).val();
        $("#UserGrid").saveRow(lastSelUser, false);
    
        $("#UserGrid").setRowData(lastSelUser, { ReferenceEmail: newEmail });
    
    
        var ref = $("#UserGrid").getCell(lastSelUser, 'ReferenceEmail');
        alert($(cell).val());
        alert($(ref).val());
    
    }
    

    现在我的参考电子邮件没有更新-警告 cell value 返回正确,但 ref(referenceemail) value 是未定义的,我已经检查了ID是否正确。

    我试过把 saverow setRowData 但这对结果没有影响。

    再一次, 我非常感谢对这个问题的任何和所有洞察。

    当做, 拜伦科布

    3 回复  |  直到 15 年前
        1
  •  2
  •   Oleg    16 年前

    我不确定我是否正确理解了你的问题。

    在我看来,这种用法应该使用 aftersavefunc 参数 editRow 而不是 succesfunc (见 http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#editrow )事件 后萨维丰 将被称为 数据保存后 在JQGRID中。事件 连续函数 只有在 $.ajax (没有本地数据编辑支持)并在请求完成后立即 在保存数据之前 在网格中。

    这个 后萨维丰 事件接收作为参数 rowid -修改行的ID,以及 res -来自服务器的响应。所以如果 ReferenceEmail 字段可以由服务器根据 Email 值可以使用结果。设置 参考电子邮件 你可以用的领域

    $("#UserGrid").jqGrid('setCell',rowid,'ReferenceEmail', data);
    

    哪里 data 是的新价值 参考电子邮件 .

        2
  •  0
  •   Bob    16 年前

    对于任何想知道的人,已经找到了部分解决方案。jqgrid编辑行接受以下参数:

    jQuery("#grid_id").editRow(rowid, keys, oneditfunc, succesfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc
    

    .setrowdata在successfunc中似乎不起作用,但在aftersavefunc中起作用,因此我的新调用是 $("#UserGrid").editRow(id, true, false, false, false, false, reload); 而不是 $("#UserGrid").editRow(id, true, false, reload);

        3
  •  0
  •   thanikkal    15 年前

    从jqgrid文档中:

    $("#updateButton").click( function(){
        var success=jQuery("#list5").jqGrid('setRowData',11,{amount:"333.00",tax:"33.00",total:"366.00",note:"<img src='images/user1.gif'/>"});
    
    if(success) {
    alert("Succes. Write custom code to update row in server"); 
    }
       else {
           alert("Can not update");
    }
    
    推荐文章