如何在不使用 Ajax 请求的情况下加载 jqGrid?
我发现/看到的每个 jsGrid 使用示例都显示通过 Ajax 请求加载数据。我想根据已有的数据加载网格;除非是技术要求,否则完全没有必要提出单独的请求。
我真的希望我的控制器能够提取在网格中显示所需的数据,将其传递到我的视图,并让 jqGrid 根据本地数据执行其操作,而不是发起另一个请求。我无法想象这是不可能的,但我还没有找到一个不使用 url
配置来获取 JSON 格式数据的示例。
当然,数据加载器并没有这么狭窄,但是有人可以给我指出一个不以 ajax 为中心的示例吗?
谢谢。
Every single example of jsGrid usage that I've found/seen shows data being loaded through an Ajax request. I'd like to load the grid based on data that's already available; a separate request is completely unnecessary unless it's a technical requirement.
I'd really like my controller to pull the data required for display in the grid, pass it along to my view and let jqGrid do its thing based on that local data rather than initiating another request. I can't imagine that's not possible, but I haven't found even a single example that doesn't use the url
configuration to acquire the data in JSON format.
Surely, the data loader isn't this narrow, but can someone point me to an example that isn't ajax-centric?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从3.7版本开始jqgrid已经有了完整的本地支持包括数据排序分页等。
所以你可以使用
data
或datastr
参数。localReader
的使用可以参见文档。这是一个简单的例子:Starting with the version 3.7 jqgrid has full local support including data sorting paging and so on.
So yo can use
data
ordatastr
parameter. The usage oflocalReader
can be needed see documentation. Here is simple example:请查看此处的 jqGrid 示例。展开“加载数据”并单击“数组数据”。
Look at the jqGrid examples here. Expand 'Loading data' and click on 'Array data'.