如何让jqGrid重新加载到服务器? [英] How to get jqGrid reload to go to server?

查看:96
本文介绍了如何让jqGrid重新加载到服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在loadonce设置为true的网格上使用jqGrid导航器重新加载按钮.

We use the jqGrid navigator reload button on a grid with loadonce set to true.

重新加载按钮当前不返回服务器以获取数据-我们如何才能使重新加载进入服务器以获取最新数据?

The reload button currently does NOT go back to the server to get the data - how can we get the reload to go to the server to get the latest data?

我相信我们可以使用 beforeRefresh 回调将网格data设置为json而不是local,但是我不清楚如何配置beforeRefresh方法-我不太了解文档.

I believe we can use the beforeRefresh callback to set the grid data to json instead of local but I'm not clear how to even configure the beforeRefresh method - I don't really understand the docs.

推荐答案

您不是唯一遇到问题的人.我之前回答了相同的问题.要从服务器重新加载网格内容,应将datatype参数重置为原始值"json"或"xml",然后刷新网格.例如

You are not the only person which has the problem. I answerd to the same question before. To reload the grid content from the server you should reset the datatype parameter to original value "json" or "xml" and then refresh the grid. For example

jQuery("#list").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');

已更新:要调用

UPDATED: To call the line inside of beforeRefresh event handler you can do following

jQuery("#list").jqGrid('navGrid','#pager',
  { edit:false,view:false,add:false,del:false,search:false,
    beforeRefresh: function(){
        alert('In beforeRefresh');
        grid.jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');
    }
  });

我从一个古老的问题中修改了一个例子. 在这里,如果您点击刷新按钮,则可以实时查看代码工作.

I modified an example from am old question. Here if you click on the refresh button you can see live how the code work.

更新2 :免费jqGrid 支持一些新选项. reloadGrid事件支持fromServer: true参数,该参数可用于强制从服务器重新加载数据,而navGrid支持reloadGridOptions选项,该选项可用于指定单击刷新按钮时使用的reloadGrid选项.所以上面的代码可能是

UPDATED 2: Free jqGrid supports some new options. reloadGrid event supports fromServer: true parameter which can be used to force reloading of data from the server and navGrid supports reloadGridOptions option which can be used to specify the options of reloadGrid used on click on Refresh button. So the above code could be

$("#list").jqGrid("navGrid", {
    edit: false,
    add: false,
    del: false,
    search: false,
    reloadGridOptions: { fromServer: true }
});

通过一种方式,可以使用jqGrid的navOptions选项指定navGrid的默认选项(请参阅Wiki文章).它允许编写类似

By the way one can use navOptions option of jqGrid to specify default options of navGrid (see the wiki article). It allows to write the code something like

$("#link").jqGrid({
    // all typical jqGrid parameters
    datatype: "json", // or "xml"
    loadonce: true,
    pager: true, // no empty div for page is required
    navOptions: {
        edit: false,
        add: false,
        del: false,
        search: false,
        reloadGridOptions: { fromServer: true }
    }
}).jqGrid("navGrid");

这篇关于如何让jqGrid重新加载到服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆