doulaobi7988 2015-03-17 07:23
浏览 221

编辑并保存任何行后重新加载JqGrid表

I have 4 jqGrid tables in a php file and passsing different json array for the each grid tables.The data which i am displaying on grid are from 1 table with different sql conditions.

I am using inline editing functionality for all the grids and when i edit and save the row from table1, i want all the grids should get refresh so that if the row which was previously edited is exists in next tables that should get vanished automatically. I want to reload the all the grid tables after editing any row in any table. I have written the following code:

<table id="jqgrid"></table>
<div id="pjqgrid"></div>

<table id="jqgrid1"></table>
<div id="pjqgrid1"></div>

<table id="jqgrid2"></table>
<div id="pjqgrid2"></div>

<table id="jqgrid3"></table>
<div id="pjqgrid3"></div>

<script>
pageSetUp();
var myEditOptions = {
    keys: true,
    successfunc: function (response) {
       // alert(JSON.stringify(response)); 
        var msg=response.responseText;
        var n =msg.search("Updated");
        //alert(n);
        if(n>=0)
        {
            $(".inner").html("<div class='alert alert-success fade in'>     <button class='close' data-dismiss='alert'>X</button><i class='fa-fw fa fa-thumbs-up'></i>  "+msg+" </div>");
        } 
        else
        {
            $(".inner").html("<div class='alert alert-danger fade in'><button class='close' data-dismiss='alert'>X</button><i class='fa-fw fa fa-thumbs-down'></i>  "+msg+" </div>");      
        }
        $("#jqgrid").trigger('reloadGrid');
        $("#jqgrid1").trigger('reloadGrid');
        $("#jqgrid2").trigger('reloadGrid');
        $("#jqgrid3").trigger('reloadGrid');
        jQuery("#jqgrid").jqGrid('resetSelection');
        jQuery("#jqgrid1").jqGrid('resetSelection');
        jQuery("#jqgrid2").jqGrid('resetSelection');
        jQuery("#jqgrid3").jqGrid('resetSelection');
        return true;     
    },
    errorfunc: function (rowid,response) {
        //alert(rowid);
    },
    afterrestorefunc:function (rowid,response) {
        jQuery("#jqgrid").jqGrid('resetSelection');
    }

};
</script>
  • 写回答

1条回答 默认 最新

  • dtbiszu7724 2015-03-17 08:10
    关注

    It would you recommend to use aftersavefunc instead of successfunc for reloading of the grids. Moreover you should place .trigger("reloadGrid") inside of setTimeout. It will allows to finish processing of editing before starting reloading:

    var myEditOptions = {
        keys: true,
        aftersavefunc: function () {
            setTimeout(function () {
                $("#jqgrid,#jqgrid1,#jqgrid2,#jqgrid3").trigger("reloadGrid");
            }, 50);
        },
        ...
    };
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题