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

add row and column totalling dynamically?

5 Answers 205 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David Avery
Top achievements
Rank 1
David Avery asked on 09 Apr 2013, 08:27 PM
Hi everyone

I am generating a pivot and need to have a row and column total.  This is dynamic, and my output looks like this:
I am using AutoGenerateColumns="True".

My output looks like this:
ZipCode       2012.01   2012.02 ... 2013.01
06477      1   7      8

I would like a total across, and full totalling on the bottom.  For now, I am doing it at the datset level, as I dont know what the cols look like.  However, I do know that any column beginning with a number needs to be totalled.

I tried a number of tricks, but I would like to get this to happen using a dynamic (calc) column and a dynamic footer item for each data column.  I tried a prerender solution, but I dont seem to have any columns available at that time.

Can anyone help?

Thanks

5 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 12 Apr 2013, 10:31 AM
Hi David,

Could you please try using the RadPivotGrid control (instead of RadGrid) which is designed for such cases and let me know if it covers your requirements?

Looking forward for your reply.

Greetings,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
David Avery
Top achievements
Rank 1
answered on 13 Apr 2013, 09:20 PM
I would love to, which is why I was so excited to see your control.  However, there is no export, which all customers want, always ;)

I would love to be able to solve this without having to manufacture computed columns and rows.
0
Radoslav
Telerik team
answered on 17 Apr 2013, 02:06 PM
Hi David,

Unfortunately the current version of the RadPivotGrid does not have export functionality. The good news is that we have plans for implementing it and at the moment our developers perform research about how to implement it. However since the RadPivotGrid is a very complicated control we cannot commit the exact time when the export functionality will be implemented.

Greetings,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
David Avery
Top achievements
Rank 1
answered on 17 Apr 2013, 02:45 PM
ok, but back to the original question, I have seen some examples where the itemcreated is used, or prerender to build these footer totals.

Ideally, I would like to say "if the column begins with a number, or follows a certain prototype ("####-##") then it gets totalled.  Any sample code around for somewthing like this?  There are some that are close, but rely upon knowing the column names.  Heck, I would even be comfortable specifying a starting sum column.
0
Radoslav
Telerik team
answered on 22 Apr 2013, 06:17 AM
Hi David,

Unfortunately the desired functionality is not supported into the RadGrid. Yes, you can handle the PreRender event and iterate over all columns, you can access the cells by their indexes and find the values into them, however you cannot insert rows and columns dynamically, because the RadGrid is a data bound control and it shows the data from the data source. So, in your case you need to modify the data source to which the RadGrid is bound. Then on PreRender event you can apply different styles to the totals and grand total rows/columns. For example you can create an in-memory DataTable which contains calculated totals and grand total rows/column and use it as data source of the RadGrid.

I hope this helps.

Greetings,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
David Avery
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
David Avery
Top achievements
Rank 1
Share this question
or