jqGrid - how to set grid to NOT load any data initially?

依然范特西╮ 提交于 2019-12-02 20:32:54

You should just use datatype: 'local' initially. At the moment when you need to load the data you should change the datatype to json or xml:

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

I wanted to create a grid that loads no data when the page is loaded but loads data, when the user clicks refresh or uses the search. My solution is a little bit hacky to but is very easy and works nicely.

I am using the callback event loadBeforeSend to stop the ajax request for data when the page is loaded. My callback function removes itself so it will be executed only once.

loadBeforeSend: function (xhr, settings) {
  this.p.loadBeforeSend = null; //remove event handler
  return false; // dont send load data request
}

Do not set URL when you initialize the Grid. Set URL just before loading the grid using setGridParam function.

It works for me.

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