This is a migrated thread and some comments may be shown as answers.

(custom) aggregate problem with filtering and paging

0 Answers 137 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RR SoftSol
Top achievements
Rank 1
RR SoftSol asked on 10 May 2012, 10:00 AM
Dear Telerik,

I'm experiencing a small problem regarding the radgrid in combination with filtering, paging and using a custom aggregate function.

The scenario is as following:

We have a grid with 1 mastertableview. The columns are not auto generated, but are either bound or a template.
The grid supports filtering (both textbox and combobox filering in the column headers). Also paging is enabled.

In the grid we have 3 columns, named ColumnA, ColumnB, ColumnC.
ColumnC is the calculated result of ColumnA x ColumnB.
Below ColumnA and ColumnC we show 2 total footers. For this we used the aggregate function SUM. This works like a charm, and the totals are shown in the footer of the grid.This is the total of ALL items currently available in the grid. In other words, the total does both respect the filter and the paging. (say my datasource has 100 items, my filter reduces it to 70, and my page shows 50 items, the sum is calculated over 70 items, this is what we want).

In the footer of the ColumnB we want to show an average in the form of SUM(ColumnC) / SUM(ColumnA). For this we can't simply use the aggregate function AVG on ColumnB as it would give a different result than the one we need.

Whats the best approach to get the desired functionality?

I've tried to use the item databound event, but then it ignores the filter and i get to many items.
I've tried to use the custom aggregate function, but when i access the items from the masterviewtable, it only returns me the items of the current page i am in.

Atm i solved it in the pre render method. There i accesed the footer items for ColumnA and ColumnC, parsed the text properties back to values and calculated the result, and then set it to the footer of ColumnB.

But i am sure there must be some other approach.

Thanks in advance,

Ramon

No answers yet. Maybe you can help?

Tags
Grid
Asked by
RR SoftSol
Top achievements
Rank 1
Share this question
or