0

I am sending json encoded results from my controller to my view and displaying data in jqgrid. The data is displaying fine. However, I added two integers to the response I am returning and I want to display them in the grid in one of the column's summary. This is what it looks like in the controller:

    $response->TotalNum = $total_items;
    $response->PercentNum = $percent_items;
    return json_encode($response);

How do I access those values in my grid? I would like to append them to the summary. Sort of like this, though I know this won't work:

{name:'itemcounts',index:'itemcounts', width: 50, sorttype:'int',summaryType:'sum', summaryTpl: 'Total<br>Count: {0}<br>Total Items: **$response['TotalNum']** (**$response['PercentNum']**%)', formatter:'number',formatoptions:{decimalPlaces: 0}},

Thank you!

Lou
  • 918
  • 3
  • 16
  • 29

1 Answers1

1

The easiest way to display summary row and fill it with the data prepared on the server is the usage of additional userdata property in the server response (its values mast be an object with properties defined as the column names) and options footerrow: true and userDataOnFooter. The old answer provides the corresponding example. If you prefer calculate the values for the footer row on the client side (which can be slowly) then you can calculate the summary using getCol and then call footerData explicitly inside of loadComplete callback. By the way the setting summaryType:'sum' will be used in case of groping of data (see here for example).

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798