jqGrid Refreshing Local Data (JSON Object)

前端 未结 6 1794
走了就别回头了
走了就别回头了 2021-01-31 18:44

I\'m trying to use jqGrid with local data and I\'m finding a couple of issues:

I\'m initializing the thing like so:

function refreshGrid($grid, results)
         


        
6条回答
  •  不要未来只要你来
    2021-01-31 19:15

    I haven't found a good documented way to update jqGrid's local data, here is how I extended jqGrid to solve my problem:

    $.extend($.fn.jqGrid, { setData: function(data) {
        this[0].p.data = data;
        return true;
    } } );
    

    After this you can do the following to update jqGrid with new data:

    suppose your grid was declared like this:

        jQuery("#list").jqGrid({ datatype: "local", ... other params ... });
    

    then you can do:

    jQuery("#list").jqGrid('setData', array_with_new_data);
    jQuery("#list").trigger("reloadGrid");
    

    P.S. see the link on how to fetch all data from the grid Retrieving contents of the grid

提交回复
热议问题