title: How to show total of subgrid footer data in parent jqGrid footer
body: <p>I need to have jqGrid with subgrid, in which I will be loading all jqGrid data (both parent &amp; subgrids) from single stored procedure. Wherein my SP is returning me the table with following columns.</p>
  
  <pre><code>Login | ReadingID | Role | Update Time | Comments
  </code></pre>
  
  <p>I want to show Login name in Parent jqGrid. This will be the only column in parent Grid.
  &amp; for each of this record I need to have subgrid showing Reading ID records corresponding to that Login. The Reading ID may have repeated entries for any Login. There is one to many cardinality between Login &amp; ReadingID. Now I want to show distinct Reading ID count &amp; UpdateTime count for each Login in subGrid footer. &amp; further I want to have total of all this subgrids footer totals in footer of Parent Grid.</p>
  
  <p>I hope the requirement is clear enough. Did anybody have implemented such jqGrid or created demo.</p>
  
  <p><strong>Update to describe requirement &amp; chosen solution</strong>
  <img src="https://i.stack.imgur.com/dMx3U.png" alt="enter image description here"></p>
  
  <p>I am using the grid definition as follows</p>
  
  <pre><code>mygrid = $("#RptDocRelease");
  
      // create the grid without filling it (datatype: "local")
      mygrid.jqGrid({
          datatype: 'local',// to revent initial loading of the grid
          postData: {
              FromDate: function () { return $("#FromDate").val(); },
              ToDate: function () { return $("#ToDate").val(); }
          },
          url: '@Url.Action("DocReleaseProductivityList", "Reports")',
          jsonReader: { repeatitems: false, root: "DocRows" },
          colNames: ['@VirtuOxAdmin.DocReleaseProductivity_Grid_RptDocRelease_Login'],
          colModel: [{ name: 'Login', index: 'Login', }],
          idPrefix: mainGridPrefix,
          subGrid: true,
          gridview: true,
          viewrecords: true,
          pgbuttons: false, pginput: false,
          recordtext: 'Total Rows:{2}',
          emptyrecords: 'Total Rows:0',
          pager: '#LogPager',
          caption: '@VirtuOxAdmin.DocReleaseProductivity_Grid_RptDocRelease_Title',
          height: 'auto',
          width: 770,
          userDataOnFooter: true,
          hidegrid: false,
          headertitles: true,
          loadError: function (xhr, status, error) {
              alert(status + " " + error);
          },
          beforeProcessing: function (data) {
              var rows = data.DocRows, l = rows.length, i, item, subgrids = {};
              for (i = 0; i &lt; l; i++) {
                  item = rows[i];
                  if (item.id) {
                      subgrids[item.id] = item.ReadingList;
                  }
              }
              data.userdata = subgrids;
          },
          subGridRowExpanded: function (subgridDivId, rowId) {
              var $subgrid = $("&lt;table id='" + subgridDivId + "_t'&gt;&lt;/table&gt;"),
                  pureRowId = $.jgrid.stripPref(mainGridPrefix, rowId),
                  subgrids = $(this).jqGrid("getGridParam", "userData");
  
              $subgrid.appendTo("#" + $.jgrid.jqID(subgridDivId));
              $subgrid.jqGrid({
                  datatype: "local",
                  data: subgrids[pureRowId],
                  jsonReader: { repeatitems: false },
                  colNames: ['@VirtuOxAdmin.DocReleaseProductivity_Grid_RptDocRelease_ReadingID',
                              '@VirtuOxAdmin.DocReleaseProductivity_Grid_RptDocRelease_Role',
                              '@VirtuOxAdmin.DocReleaseProductivity_Grid_RptDocRelease_UpdateTime',
                              '@VirtuOxAdmin.DocReleaseProductivity_Grid_RptDocRelease_Comments'
                  ],
                  colModel: [
                      { name: 'ReadingID', index: 'ReadingID', width: 80, fixed: true, sorttype: "integer" },
                      { name: 'Role', index: 'Role', width: 100, fixed: true },
                      {
                          name: 'UpdateTime', index: 'UpdateTime', width: 80, fixed: true, sorttype: "date", formatter: "date",
                          formatoptions: { srcformat: "m/d/Y h:i:s", newformat: "m/d/Y h:i:s A" }
                      },
                      { name: 'Comments', index: 'Comments' }
                  ],
                  cmTemplate: { align: 'center', sorttable: false, cellattr: function () { return 'style="white-space: normal!important;' } },
                  height: 'auto',
                  width: '100%',
                  hidegrid: false,
                  viewrecords: true,
                  pgbuttons: false, pginput: false,
                  recordtext: 'Total Rows:{2}',
                  emptyrecords: 'Total Rows:0',
                  pager: rowId + '_Pager',
                  userDataOnFooter: true,
                  headertitles: true,
                  gridview: true,
                  loadError: function (xhr, status, error) {
                      alert(status + " " + error);
                  },
                  gridview: true,
                  idPrefix: rowId + "_"
              });
              $("#" + rowId + "_Pager").navGrid('#LogPager', { edit: false, add: false, del: false, search: false, refresh: false })
          }
      });
      mygrid.navGrid('#LogPager', { edit: false, add: false, del: false, search: false, refresh: false })
      .closest(".ui-jqgrid").hide();
  </code></pre>
  
  <p>&amp; Server data will be returned in following structure</p>
  
  <pre><code> public struct JQGridResult
      {
          public int page;
          public int total;
          public int records;
          public List&lt;ReportData&gt; DataRows;
          public List&lt;DocRelease&gt; DocRows;
          public object userdata;
      }
  
  
   public struct DocRelease
      {
          public string Login { set; get; }
          public List&lt;Readings&gt; ReadingList { set; get; }
          public object userdata;
      }
  
  public struct Readings
      {
          public int ReadingID { set; get; }
          public string Role { set; get; }
          public DateTime UpdateTime { set; get; }
          public string Comments { set; get; }
      }
  </code></pre>