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

Running total column in a RadGrid

5 Answers 251 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jerry
Top achievements
Rank 2
Jerry asked on 09 Sep 2008, 04:39 PM
I have a RadGrid that has 3 data bound columns: date, enrollments, drops. I would like to add a running total column that shows the total enrollments for each date.

It seems like I should be able to do this with a calculated column but I am not seeing how. I am using the latest version of the control. Does anyone have any tips?

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 12 Sep 2008, 05:05 PM
Hello Jerry,

Take a look at this sample code:
<telerik:GridNumericColumn DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" 
    UniqueName="UnitPrice" DataType="System.Decimal"
</telerik:GridNumericColumn>

<telerik:GridBoundColumn DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" 
    UniqueName="UnitsInStock" DataType="System.Decimal"
</telerik:GridBoundColumn> 
                  
<telerik:GridBoundColumn DataField="UnitsOnOrder" HeaderText="UnitsOnOrder" SortExpression="UnitsOnOrder" 
    UniqueName="UnitsOnOrder" DataType="System.Decimal"
</telerik:GridBoundColumn>

<telerik:GridCalculatedColumn HeaderText="Total" UniqueName="Total" DataFields="UnitPrice, UnitsInStock, UnitsOnOrder" 
    Expression="{0}*{1}*{2}" DataType="System.Double"
    <ItemStyle HorizontalAlign="Right" Width="80px"></ItemStyle> 
</telerik:GridCalculatedColumn> 

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jerry
Top achievements
Rank 2
answered on 12 Sep 2008, 05:30 PM
Thank you for the reply Daniel. I see where your code example would provide a total for that row but not a running total.

For example (hopefully the formatting leaves this readable):

Date         Enrollments   Drops  DayTotal  RunningTotal
9/12/08    10                 2         8               8
9/13/08    15                 5         10             18
9/14/08    5                   10       -5              13
9/15/08    10                 0         10              23

In this example, DayTotal would be a calculated column like your example showed and would consist of Enrollments minus Drops.

Yet to provide the running total, I would need to take the value from the previous row if this is not the first row of the grid. I could do this through code but was hoping for a non-code solution if one is possible with a RadGrid.

I hope this clarifies what I am looking for and appreciate the input.

Thanks,
Jerry
0
Daniel
Telerik team
answered on 15 Sep 2008, 05:16 PM
Hello Jerry,

Currently our RadControls for ASP.NET AJAX doesn't offer such a codeless functionality. Alternatively you can either implement it client-side or server-side depending on your scenario.

Let us know if you need assistance with the aforementioned functionality.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Doug
Top achievements
Rank 2
answered on 06 Jul 2018, 10:51 AM
Since this is found in a google search, and has been resolved by the 2018 release - might be nice to have a link to the release notes that fixed this? Or allow us to flag such finds to the admins, because the google find is important and but between  Mar 2006 and 2018 a lot has changed.
0
Marin Bratanov
Telerik team
answered on 10 Jul 2018, 01:33 PM
Hi Doug,

Writing up a comment like you did can be used to flag a thread for review.

I am not sure I understand the issue, however. A running total needs values from previous rows, and RadGrid still does not offer such a feature out-of-the-box. Could you provide a link or some more details as to what you have in mind?


Regards,
Marin Bratanov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Jerry
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Jerry
Top achievements
Rank 2
Doug
Top achievements
Rank 2
Marin Bratanov
Telerik team
Share this question
or