The strust 2 jquery grid plugin does not support summaryType for columns, as a work around I try to set it as:
$("#gridtable").jqGrid('setColProp', 'amount',{summaryType:'sum'});
This does not work at the first time. But after reloading the grid, or sorting some columns, the summary is displayed.
It seems that the summaryType needs to be defined before grid is constructed. I try to call setColProp in onBeforeTopics but it didn't worked again.
So is there any way I set column property before grid constructed ?!
I suppose that strust 2 jquery grid plugin uses some old jqGrid in version 4.6/4.7. Starting with version 4.4.4 jqGrid supports
onInitGridcallback andjqGridInitGridevent which could be very helpful in your case. The callback/event will be called/triggered after the outer elements of jqGrid will be build (column headers for example), but before the first filling of the grid with data (before the first call of internalpopulatemethod).Thus you can use the following code for the required changes:
It's important to understand that you can/should make the binding before creating the grid because the empty
<table id="gridtable"></table>already exist and the binding will be not changed during creating jqGrid.Free jqGrid has another callback
beforeInitGridand the corresponding eventjqGridBeforeInitGrid, which will be called earlier, before any outer parts of jqGrid will be created, but thejqGridInitGridevent would be enough for your purpose already.