Running total column in a RadGrid

4 posts, 0 answers
  1. Jerry
    Jerry avatar
    7 posts
    Member since:
    Jun 2008

    Posted 09 Sep 2008 Link to this post

    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?

  2. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 12 Sep 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jerry
    Jerry avatar
    7 posts
    Member since:
    Jun 2008

    Posted 12 Sep 2008 Link to this post

    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
  5. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 15 Sep 2008 Link to this post

    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.
Back to Top