How to suppress jqgrid to initially load data?

I have a page that has a couple of jqGrids, as well as several other fields. I want to make one AJAX call myself, which drops a JSON object that has data that should be used to fill the entire page.

So, I would like to call myself, fill in the “other fields”, and then pull out a couple of collections from the main JSON object that was returned, and fill each of jqGrids with these collections “manually”.

I have a lot of work, but I can't get jqGrid to stop trying to execute the AJAX request itself. Should there be a way to tell jqGrid not to try to make an AJAX call when it is initialized?

I found a similar question asked here: How to disconnect jqgrid from initial data loading?

But I have no way to allow it for a poster.

It seems pretty logical to me that some people may want to use this plugin without trying to get the table to get their own data during initialization. Am I missing an option somewhere in the documentation (wiki-options)?

Thanks.

+4
source share
1 answer

There is a simple way to say that jqGrid does not load the data itself. You should use datatype: 'local' as the jqGrid parameter. This parameter says that you plan to fill the grid data yourself with functions such as addRowData or addJSONData (see the example in the jqGrid tableToGrid "options" parameter ), you can also fill the data in the grid inside the loadComplete , since jqGrid calls this function also in case datatype: 'local' .

Do not forget that the data that you specify as the addJSONData parameter will be read (parsed) using jsonReader and jsonmap . This gives you a good way to not manipulate the data received from the server so much. Instead, it is enough to correctly display data in jsonmap for jqGrid. A relatively complex example of data mapping can be found in Mapping JSON Data in a JQGrid .

If you are thinking about data transfer optimization, see the "Data Mapping" \ "Data optimization" section on the http://trirand.com/blog/jqgrid/jqgrid.html demo page. The idea is to replace the data structure with the presented table rows to an array of strings. Then no column names (filed structure names) will be sent from the server to the client, which compresses the data transfer. With this optimization, you can probably save a lot more time than in another way. Remember to enable data compression on the web server. It can also significantly reduce the size of data transfer.

In the end, I can recommend looking at my discussion question. Should I replace using addJSONData jqGrid with using setGridParam () and trigger ('reloadGrid')? , where I compare the use of the addJSONData () function using a trigger ('reloadGrid'). The reason is that if you want to update more, since one table of a trigger immediately ("reloadGrid") will be a little slower, as if you made only one ajax call, but the structure of your program will be much simpler using a trigger ('reloadGrid') . If you compare the total time in both cases, it may happen that data transfer is not the bottleneck that you have. Thus, it may be that the total page load time in both cases remains virtually unchanged. The best way would be to save time in both cases and decide how much you are willing to pay for a simple program design.

+8
source

Source: https://habr.com/ru/post/1308496/


All Articles