Question

UPDATE: Found solution, check comments since I am still a noobie user who has to wait 8 hours.

I have a strut2 jquery grid along with a form on my webapp's landing's page. The grid is populated and made visible via ajax call when the form is submitted. It was functioning incorrectly at first since the grid would make an ajax call initially when the user hits the landing page making unnecessary requests.

I fixed this with hiddengrid="true" and now the grid does not make any initial requests when the landing page is first hit, which is good. But now my ajax call does not work at all when I submit the form. It does not even reach the action.

Setting that above attribute to true has something to do with it but I am not sure how to fix the issue.

TL;DR Struts2 jQuery grid no longer hits 'url' after setting hiddengrid="true". Setting the attribute to false fixes the issue but then the grid makes an initial unnecessary request.

Any help would be greatly appreciated Thanks!

Was it helpful?

Solution

Looks like I have been searching the wrong keywords. Doing a google search on 'jquery grid initial data' instead of 'struts 2 jquery grid ..' brought me to a quick and painless fix. Anyway here is the quick fix in case anyone runs into similar issue:

Source

Set the grid attribute initially:

datatype: local 

In your ajax call set the grid attribute to 'json' (assuming you are working with JSON data)

$('#my-jqgrid-ID') .jqGrid('setGridParam', { 'datatype' : 'json' }) .trigger('reloadGrid');

OTHER TIPS

The code adds rows, in case ur looking for only new values on each grid load use this:

     var allParameters = $("#gridId").jqGrid("getGridParam");
                        allParameters.data = myData;
                        $("#gridId").trigger('reloadGrid');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top