Running total column in a RadGrid

6 posts, 0 answers
  1. Jerry
    Jerry avatar
    8 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
    4949 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. Jerry
    Jerry avatar
    8 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
  4. Daniel
    Admin
    Daniel avatar
    4949 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.
  5. Doug
    Doug avatar
    11 posts
    Member since:
    Mar 2006

    Posted 06 Jul 2018 in reply to Daniel Link to this post

    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.
  6. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5122 posts

    Posted 10 Jul 2018 Link to this post

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