Hello there,
is there a way to access additional payload that is send within a JSONresponse to an igGrid?
e.g.
Currently the igGrid gets filled with a JSON object looking like this:
{Records: DATA, TotalRecordsCount: 0}
Now I want to send something like this:
{Records: DATA, TotalRecordsCount: 0, Sums: DATA2}
And then in igGrids OnDataBound I want to access "Sums" and fill it into the Headers for my columns in the igGrid.
I am calculating the sum of some columns on the server because the client uses paging and is not aware of the whole data content to work with. Also i know i could store it on the server in a 2min cache or whatever and make a 2nd ajax call in the OnDataBound to retrieve the sums for my columns but i would rather not do a 2nd request to the server just for some minor data.
While in the DataBound event i can see the "_ajaxRequest.responseText" inside the a.dataSource object (function gridDataBound(e, a))... but I don't think that would be the right way to access the data and I cannot find a method to get the full response only the mapped ones from "Records".
Long story short, how to access the full JSON response that is requested by the igGrid on filter/sort updating.
Hi Jean-Paul,
Thank you for posting in our forums!
I am investigating what the best method would be to access your additional data during the grid's ajax calls.
I will have more information or questions for you tomorrow.
Hello Jean-Paul,
I've discussed this with more team members and we have the following suggestions:
If your data set is not very large you can call JSON.Parse on the _ajaxRequest.responseText that you found in the OnDataBound event. If performance is a big concern for you, you would not want to call JSON.Parse on a large data set since we already do that. Then, you can extend the igDataSource widget and define your own _processJsonResponse method (_processJsonResponse: function (data, context) {). This method is responsible to how the igDataSource maps and interprets the data from the ajax response.
If you have any further questions or concerns with this, please let me know and I will be glad to help.
Hello Michael,
thanks for your reply.
I suspected that i would have to dig into the igDataSource directly via the _processJsonResponse.
As we are paging the data and thus have no big chunks to chew on i will be calling another parse on the response to get what i need.
Thank you for your assistance on this matter.
Jean-Paul