Add a row

5 posts, 0 answers
  1. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 22 Nov 2011 Link to this post

    I have a grid that I'm just binding to a table in a database. Is there a way to put one more row on the end of that from the server? Essentially, I want to get the totals from that table and put in on the end of the grid as totals. so it would look something like this

    Customer1 1 1 4 3
    Customer2 1 2 3 5
    Totals Here 2 3 7 8

    Where Customer1 and Customer2 came from the table, and then totals here was added in the code behind. Is this possible?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 Nov 2011 Link to this post

    Hello,

    To get the total of each column at the end you can set ShowFooter property as true and set Aggregate property of each column as Sum. Here is the sample code.

    ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false"  DataSourceID="SqlDataSource2" ShowFooter="true">
      <MasterTableView CommandItemDisplay="Top">
         <Columns>
            <telerik:GridBoundColumn UniqueName="quantity" HeaderText="quantity" DataField="quantity" Aggregate="Sum" >
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="item" HeaderText="item" DataField="item">
           </telerik:GridBoundColumn>
        </Columns>
     </MasterTableView>
    </telerik:RadGrid>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. RvdGrint
    RvdGrint avatar
    112 posts
    Member since:
    May 2011

    Posted 23 Nov 2011 Link to this post

    You also can design a RadGrid based on a custom datatable (filled with the table data). That makes it possible easily insert more than 1 line at once  and you  can cummulate columns your self in a standaard gridrow.

    Let me know if you need an example

    Regards,
      Jos
  5. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 23 Nov 2011 Link to this post

    I know how to bind to a data table, I was just trying to avoid that :). When I put the grid column in you mentioned I get a 

    Sum is not supported for type "System.Object"


    error. I guess I'll just create a data table
  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Nov 2011 Link to this post

    Hello,

    You can make sure that the DataType set in the column is same as that used in DataBase.

    Thanks,
    Princy.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017