jqGrid:AfterSave方法未触发,当使用动作格式化程序和过滤器编辑单元格值时,则显示具有新单元格值和过滤网格的网格

时间:2015-09-17 20:43:32

标签: jqgrid

我正在尝试使用动作格式化程序来启用内联网格编辑。我已经将网格设置为loadonce:true并且正在检索JSON数据以填充网格。

我还添加了一个导航栏按钮来过滤行中全部为零的单元格值,以便仅显示至少有一个非零值的行。

尝试编辑已过滤的行时,如何编辑单元格值,将值发送到服务器,重新加载网格,然后将过滤器应用于网格?

我尝试在formatStion函数中添加一个触发器来重新加载网格,但是没有显示新值,显示原始值并将过滤器应用到网格也失败。

$grid.jqGrid({ 
    url: gridLoadURL,
    datatype: "json",
 mtype: "GET",
 caption: gridCaption,
 loadonce: true,
 majCostExcel: majCostExcel,
 //loadCostRowData: CostRowData,
 editurl: CostRowData,
 loadCostData: CostData,
 //footerrow: false,
 altRow: true,
 altClass: "altRow",
 loadtext: "Loading",
 colNames: ['Actions','Allocation ID','Project Name','2012 Qtr 1','2012 Qtr 2','2012 Qtr 3','2012 Qtr 4','2013 Qtr 1','2013 Qtr 2','2013 Qtr 3','2013 Qtr 4','2014 Qtr 1','2014 Qtr 2','2014 Qtr 3','2014 Qtr 4','2015 Qtr 1','2015 Qtr 2','2015 Qtr 3','2015 Qtr 4','2016 Qtr 1','2016 Qtr 2','2016 Qtr 3','2016 Qtr 4','2017 Qtr 1','2017 Qtr 2','2017 Qtr 3','2017 Qtr 4','2018 Qtr 1','2018 Qtr 2','2018 Qtr 3','2018 Qtr 4','2019 Qtr 1','2019 Qtr 2','2019 Qtr 3','2019 Qtr 4'], 
colModel: [
{ name: 'act', index: 'act', width: 50, align: 'center',sortable: false, formatter: 'actions', frozen: true, hidedlg:true,
                  formatoptions: {
                    //url: $(this).jqGrid('getGridParam',"loadCostRowData"),
                    onSuccess:true,
                    afterSave: function(){
                       $(this).jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');
                    //$(this).jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid',[{current:true}]);
                    jqGridFilter(null,$(this),0); 
                    jqGridFilter(filters , $(this),1); 
                    },

                    editbutton: true, 
                    delbutton: false,

                  },
              },
   {name: 'project_id',width:60,sortable:false,formatter:fontColorFormat,align: 'right',
    //sorttype:'int',
    frozen: true, hidedlg: true},

这是过滤网格行的功能:

    function jqGridFilter(filtersparam, grid, reload) {
 grid.setGridParam({
    postData: {
        filters: filtersparam
    },
    search: true
 });
 if(reload == 1){
    grid.trigger("reloadGrid");
 }
    };

过滤器是:

    var filters = { "groupOp": "OR", "rules": [{ "field": "y2012qval1", "op": "ne", "data": "0" },{ "field": "y2012qval2", "op": "ne", "data": "0" },{ "field": "y2012qval3", "op": "ne", "data": "0" },{ "field": "y2012qval4", "op": "ne", "data": "0" },{ "field": "y2013qval1", "op": "ne", "data": "0" },{ "field": "y2013qval2", "op": "ne", "data": "0" },{ "field": "y2013qval3", "op": "ne", "data": "0" },{ "field": "y2013qval4", "op": "ne", "data": "0" },{ "field": "y2014qval1", "op": "ne", "data": "0" },{ "field": "y2014qval2", "op": "ne", "data": "0" },{ "field": "y2014qval3", "op": "ne", "data": "0" },{ "field": "y2014qval4", "op": "ne", "data": "0" },{ "field": "y2015qval1", "op": "ne", "data": "0" },{ "field": "y2015qval2", "op": "ne", "data": "0" },{ "field": "y2015qval3", "op": "ne", "data": "0" },{ "field": "y2015qval4", "op": "ne", "data": "0" },{ "field": "y2016qval1", "op": "ne", "data": "0" },{ "field": "y2016qval2", "op": "ne", "data": "0" },{ "field": "y2016qval3", "op": "ne", "data": "0" },{ "field": "y2016qval4", "op": "ne", "data": "0" },{ "field": "y2017qval1", "op": "ne", "data": "0" },{ "field": "y2017qval2", "op": "ne", "data": "0" },{ "field": "y2017qval3", "op": "ne", "data": "0" },{ "field": "y2017qval4", "op": "ne", "data": "0" }] }; 

在网格实例化之前声明并分配jqGridFilter函数和filters变量。

任何提示或建议在哪里查看?

非常感谢!

0 个答案:

没有答案