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

前端 未结 3 837
一整个雨季
一整个雨季 2021-02-01 18:46

How can you create a grid but not load any data?

If I omit the url option then the loadError callback is triggered.

Currently we set

相关标签:
3条回答
  • 2021-02-01 19:14

    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');
    
    0 讨论(0)
  • 2021-02-01 19:14

    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
    }
    
    0 讨论(0)
  • 2021-02-01 19:38

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

    It works for me.

    0 讨论(0)
提交回复
热议问题