Hi Infragistics,
I am currently trying to implement load on the demand for the hierarchical grid without using MVC or oData. As far as I have figured out this is doable by catching the ajax GET request and modify its query string in order to get the information you want from the client side to the server side. I am however having trouble getting information about what row has been clicked before the ajax GET event fires. Both the igchildgridcreating and rowExpanding events fire after the ajax GET event fires so I cannot get any information about what has actually been clicked in the grid. I have also tried and catch the click event on the actual class for the expand row button but without any luck.
Are there any events, html classes, or IDs I can catch any event on before the ajax GET is sent which will give me the same or similar information that one can get from the rowExpanding event?
I am using this to catch the ajax Get event.
$(document).ajaxSend(function (e, jqXHR, options) { if (options.url.indexOf("/Handler2.ashx") != -1) { options.url += '¶m1=value1'; }});
In summary. What I need so to add a string on the format "[0321]" to the query string of the ajax GET call. Where "[0321]" represents the index of each row clicked on each level in the hierarchy of the grid; hence [0321] represents the 1st row on level 0, 4th row on level 2, 3rd row on level 3, and 2nd row on level 4.
Best Regards
Fred
UPDATE:
I managed to change the ajax url before if was sent to the server and now I am able to parse it and create the data source for each level as I wanted to do.
I do however have problems formatting the data source for all levels but the initial grid on level_0. When I load the grid for the first time it loads level_0 without any problems. The json that does this is build up as a flat grid containing column headers and their values. However when expanding a row to level_1 and providing the grid with json structured in the same way but with data for that particular row and for level_1 I get the following error message from infragistics.lob.js
"
JavaScript runtime error: The remote request to fetch data has failed: (parsererror) There was an error parsing the JSON data and applying the defined data schema: The input data doesn't match the schema, the following field couldn't be mapped: level_2
Does the grid try and parse data for level_2 even though I am only interested in load the data for level_1 for the particular row that was clicked? How can I fix this? Or do I just need to provide an empty set in the json for level_2 so that the hierarchical grid generates the + (expand row) icons for the rows in level_1. How does this json need to look in that case?
F
Solved it all.
For those if you who are interested in all the details here is a list of things that was done.
- Catch the ajax event in the $(document).ajaxSend event.
- Parse out the row(s) data-id(s) from the ajax url.
- Search the DOM for the row you just clicked and calculate the path to this element. Here it gets a bit tricky and unstable because the hierarchical grid will have the same data-id for the last and second to last row in the grid on all paths. Hence one has to parse the DOM of the grid in levels. From the ajax url you should have the ids of all the rows on the path to the row you clicked. Take the first ID and get its row by running $("tr[data-id=xxxxx]") and then get its sibling tr because a row that has a subgrid will have a sibling tr containing this grid. Hence all ids obtained from the ajax url will have a sibling tr containing a sub grid. Once you find the row you actually clicked you will also know the path to this row in terms of which row indexes that were clicked and in what order. Something I had to know since the grid DOM ids had no mapping against my server side data source.
- Append the path to the ajax url and send it to the server.
- Create a flat grid data source for the level in the grid that is about to be opened and send it back.
- Make sure you set localSchemaTransform: false, odata: false, rest: false, initialDataBindDepth: 0, autoGenerateLayouts: false, autoGenerateColumns: false, generateCompactJSONResponse: false in both the initialization of the grid and on each level in the columnLayouts. Thanks to Miroslav for his example here: http://es.infragistics.com/community/forums/t/79652.aspx. I do not know if all of the once above are needed for example the rest variable, but most of them are needed for it to work properly for me.
Thx!
Hello F K,
Thank you for contacting Infragistics!
I a glad you are able to move forward with your application.
If you have any questions, please do not hesitate to let us know as well.