How to suppress jqgrid to initially load data?

I have jqgrid in a modal popup that has data depending on some input. I do this by setting an input-based grid url parameter as shown below and showing a popup:

$(ContainerGrid.Grid).setGridParam({ url: urlGetContainers + '?CRALineId=' + currentCRALineId }).reloadGrid(); 

When a grid is first loaded onto the screen, it is not displayed and data should not be retrieved until a modal pop-up window appears. Unfortunately, jqgrid is still trying to make a request for data based on its URL.

I tried using the hiddengrid property to hide / collapse the grid first, which also does not allow me to query data. This did not work, because I could not find a programmatic way to show / expand the grid.

Is there any way to suppress jqgrid from initial data loading?

+4
source share
2 answers

Initialize your grid in the Show event of the modal popup. You can dynamically generate jqGrid and embed it in the DOM, and then later bind the data using regular initialization code.

+3
source

I had the same need as you, when I need my grids to download data only after receiving the hash of the URL (the hash of the URL determines which filters are set for my grid, then the data can be loaded in the net). So to prevent my grid from loading data at startup, this is what I did:

Grid Setting:

 $("#grid").jqGrid({ url:"", mtype:"", ... 

Later, when I needed to actually load the data:

 $("#grid").jqGrid("setGridParam",{datatype: "json", mtype: 'POST', url: myUrl, postData: params}).trigger("reloadGrid"); 

I also consider it necessary to make {postData: null} before the above reload to ensure that the post variables from the previous message will not be included in future posts.

0
source

All Articles