Jqgrid data update on live function click But not updating data

送分小仙女□ 提交于 2019-12-12 00:57:50

问题


I am trying to update Jqgrid data update on live function click But not updating data.

I have tried jQuery('grid').jqGrid('clearGridData'); jQuery('grid').jqGrid('setGridParam', {data: dataToLoad}); jQuery('grid').trigger('reloadGrid');

also here is my grid code it is in a function and i am calling this function for each buttun click

  jQuery("#procedureResultGrid").jqGrid({
       loadonce:false,
    rowList : [ 10, 20, 50,100 ],
       data : jsonText,
       datatype : 'local',
       gridview: true,
       rowNum : 10,
       width : '100%',
       height : 'auto',
       colModel : [{
           name : 'name',
           sortable:false,
           width : 130,
           classes: "col1"
       },{
           name : 'rowv_1',
           formatter: valueFormatFunctionFirst,
           width : 60,
           sortable:false
       }
       ,{

           name : 'row1',
           width : 25,
           formatter: calculatedFormatFunctionFirst,
           classes: "imageValue"


       },{

           name : 'row4',
           width : 50,
           formatter: calculatedPersendFunctionFirst,
           classes: "persendValue"

        },{
           name : 'rowv_2',
           formatter: valueFormatFunctionSecond,
           width : 60,
           sortable:false
       }
       ,{

           name : 'row3',
           width : 25,
           formatter: calculatedFormatFunctionSecond,
           classes: "imageValue"

       },{

       name : 'row4',
       width : 50,
       formatter: calculatedPersendFunctionSecond,
       classes: "persendValue"
    }
       ,{
           name : 'rowv_3',
           width : 60,
           formatter: valueFormatFunctionThird,
           sortable:false
       }
       ,{

           name : 'row5',
           width : 25,
           formatter: calculatedFormatFunctionThird,
           classes: "imageValue"

       },{

       name : 'row6',
       width : 50,
       formatter: calculatedPersendFunctionThird,
       classes: "persendValue"

    }
       ,{
           name : 'rowv_4',
           formatter: valueFormatFunctionForth,
           width : 60,
           sortable:false
       }
       ,{

           name : 'row5',
           width : 25,
           formatter: calculatedFormatFunctionForth,
           classes: "imageValue"

       },{

       name : 'row6',
       width : 50,
       formatter: calculatedPersendFunctionForth,
       classes: "persendValue"

    },{
        name : 'rowv_4',
        formatter: valueFormatFunctionYTD,
           width : 60,
           sortable:false
       }
       ,{

           name : 'row5',
           width : 25,
           formatter: calculatedFormatFunctionYTD,
           classes: "imageValue"

       },{

       name : 'row6',
       width : 50,
       formatter: calculatedPersendFunctionYTD,
       classes: "persendValue"

    }
       ],
       pager : jQuery('#pager'),
       afterInsertRow: function (rowid, rowdata) {
    if(rowid%2==0)
           $("#procedureResultGrid").jqGrid('setRowData', rowid, false, { background: '#F2F2F2' });
        else
            $("#procedureResultGrid").jqGrid('setRowData', rowid, false, { background: 'white' });
       }

   });

   $("#procedureResultGrid").fluidGrid({
       base : "result-grid",
       offset : -20
   });

   $("#pager").show();
          $("#procedureResultGrid").setGridParam({datatype:'local',sortname:'values.aggregate.'+totalCostIndex+'.data.'+addKeyYear(keyYear), sortorder: 'desc'}).trigger('reloadGrid');

I am also try sort it is also not working.


回答1:


I just added from create grid and

 $("#procedureResultGrid").GridUnload();

then

   $("#procedureResultGrid").trigger('reloadGrid');

working fine for me..

Thanks



来源:https://stackoverflow.com/questions/15859346/jqgrid-data-update-on-live-function-click-but-not-updating-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!