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

Add a row

4 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Web Services
Top achievements
Rank 2
Web Services asked on 22 Nov 2011, 06:14 PM
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?

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Nov 2011, 05:05 AM
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.
0
RvdGrint
Top achievements
Rank 1
answered on 23 Nov 2011, 08:53 AM
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
0
Web Services
Top achievements
Rank 2
answered on 23 Nov 2011, 05:26 PM
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
0
Princy
Top achievements
Rank 2
answered on 24 Nov 2011, 05:15 AM
Hello,

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

Thanks,
Princy.
Tags
Grid
Asked by
Web Services
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
RvdGrint
Top achievements
Rank 1
Web Services
Top achievements
Rank 2
Share this question
or