Write a custom function in summaryType of JQgrid for subtraction of group values

I am developing a Grid using JQgrid. I’ve used GroupView and each group has 2 values. I want to subtract both values and give result in the next row.

JQgrid by default provides sum function. It doesn’t have anything for subtraction.

I’ve written below code in cellAttr property and I am able to get the subtraction value. but with cellAttr I am not able to put the result value in particular cell.

                        arr[i] = parseInt(tv,10);
                        if((rowId % 3) == 0)
                            var value = arr[i-2] - arr[i-1];
                            console.log(" Value : "+value);

I’ve tried writing the custom function in Summarytype property. But I can not access the value of each row in it. (Like I can have cell value in ‘tv’ argument of cellAttr) Is there any way I could write this logic in summaryType property or any other way I could subtract the values of group?

Source: javascript

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.