JQGrid Expanding SubGrid on page load

13 / Feb / 2011 by Tarun Pareek 4 comments

Hi,
 
Recently guys, i faced problem while expanding the JQGrid SubGrid onLoad of the page.
 
Initially, i used the following code on gridComplete Event of JQGrid, Using the code given below, i am only able to expand grid but without data populated in subgrid.

gridComplete: function() {
                var rowIds = $("#testTable").getDataIDs();
                $.each(rowIds, function (index, rowId) {
                        $("#testTable").expandSubGridRow(rowId);                   
                });
            }

After trying different ways, and many efforts i came up with this solution and it worked for me.
Solution to above problem given below :

gridComplete: function() {
                var timeOut = 50;
                var rowIds = $("#testTable").getDataIDs();
                $.each(rowIds, function (index, rowId) {
                    setTimeout(function() {
                        $("#testTable").expandSubGridRow(rowId);
                    }, timeOut);
                    timeOut = timeOut + 200;
                });
            }

It worked for me. Hope it help you too.

Thanks & regards,
Tarun Pareek
LinkedIn

FOUND THIS USEFUL? SHARE IT

comments (4)

  1. Rahul Mittal

    Thanks Tarun! Really, this was great help to me which I was looking for 4th level sub girds. It work perfectly for me.

    Reply
  2. Zane

    Thank you Tarun. This worked for me.

    Originally, I was trying to use the subGridOption and setting expandOnLoad to true, but it would only load the first subgrid.

    Using your method has worked perfectly.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *