Hi,
We are designing a reporting window using Rad-grid for our client which is a departmental store. Now the requirement is that in footer section of Rad-grid, it is required to show UNIT(PCS,Litres, mitres,,,,,,) wise summary. In the attached snap we have tried to show our exact requirement.
Please help us with suitable code..
Regards
Purojit .
We are designing a reporting window using Rad-grid for our client which is a departmental store. Now the requirement is that in footer section of Rad-grid, it is required to show UNIT(PCS,Litres, mitres,,,,,,) wise summary. In the attached snap we have tried to show our exact requirement.
Please help us with suitable code..
Regards
Purojit .
3 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 16 Jul 2013, 07:18 AM
Hi Purojit,
I guess you want to change the footer text.Please check the below code snippet,i have tried to change the text,"Sum" and "CountDistinct" to another.Please elaborate your requirements if this didn't help.
ASPX:
C#:
Thanks,
Shinu
I guess you want to change the footer text.Please check the below code snippet,i have tried to change the text,"Sum" and "CountDistinct" to another.Please elaborate your requirements if this didn't help.
ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" onitemdatabound="RadGrid1_ItemDataBound"> <MasterTableView ShowFooter="true"> <Columns> <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID" /> <telerik:GridBoundColumn DataField="Freight" HeaderText="Frieght" Aggregate="Sum" UniqueName="Frieght" /> <telerik:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID" Aggregate="CountDistinct" UniqueName="CustomerID"/> </Columns> </MasterTableView></telerik:RadGrid>C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e){ if (e.Item is GridFooterItem) { var item = e.Item as GridFooterItem; TableCell cell = item["Frieght"]; cell.Text = cell.Text.Replace("Sum", "Total Frieght"); TableCell cell1 = item["CustomerID"]; cell1.Text = cell1.Text.Replace("CountDistinct", "Distinct ID"); } }Thanks,
Shinu
0
Purojit
Top achievements
Rank 1
answered on 16 Jul 2013, 07:36 AM
Hi Shinu,
We want the footer to be displayed as per unit..There will be rows on footer where summary will be shown based on unit. Please check our snap again. You will understand.
Header Part:------SALES UNIT AMOUNT
Detail part:-------------------------------------------------------------
Footer Part:------1000 pcs 560000
2500 litres 458990
1587 kgs 78950
Thanks
Purojit
We want the footer to be displayed as per unit..There will be rows on footer where summary will be shown based on unit. Please check our snap again. You will understand.
Header Part:------SALES UNIT AMOUNT
Detail part:-------------------------------------------------------------
Footer Part:------1000 pcs 560000
2500 litres 458990
1587 kgs 78950
Thanks
Purojit
0
Hello Purojit,
I have assembled a sample page showing the desired functionality implemented. The idea is to subscribe to RadGrid ItemDataBound event and manually calculate the desired values and then set the footer cells their Text property as shown below.
Regards,
Antonio Stoilkov
Telerik
I have assembled a sample page showing the desired functionality implemented. The idea is to subscribe to RadGrid ItemDataBound event and manually calculate the desired values and then set the footer cells their Text property as shown below.
Dictionary<string, Dictionary<string, double>> aggregates = new Dictionary<string, Dictionary<string, double>>();protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e){ GridDataItem dataItem = e.Item as GridDataItem; if (dataItem != null) { string value = dataItem["Unit"].Text; Dictionary<string, double> columnValues; if (!aggregates.ContainsKey(value)) { columnValues = new Dictionary<string, double>(); columnValues.Add("Sales", 0); columnValues.Add("Amount", 0); aggregates.Add(value, columnValues); } else { columnValues = aggregates[value]; } columnValues["Sales"] += int.Parse(dataItem["Sales"].Text); columnValues["Amount"] += int.Parse(dataItem["Amount"].Text); } GridFooterItem footerItem = e.Item as GridFooterItem; if (footerItem != null) { StringBuilder value = new StringBuilder(); foreach (var pair in aggregates) { value.Append(pair.Value["Sales"]); value.Append("<br />"); } footerItem["Sales"].Text = value.ToString(); value.Clear(); foreach (var pair in aggregates) { value.Append(pair.Value["Amount"]); value.Append("<br />"); } footerItem["Amount"].Text = value.ToString(); value.Clear(); foreach (var pair in aggregates) { value.Append(pair.Key); value.Append("<br />"); } footerItem["Unit"].Text = value.ToString(); }}Regards,
Antonio Stoilkov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.