or
protected void cboAccount_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) { RadComboBox cboSite = (RadComboBox)fvIncidentEdit.FindControl("cboSite"); RadTreeView trvSite = ((RadTreeView)cboSite.Controls[2].FindControl("trvSite")); trvSite.DataSource = Models.Site.LoadActiveSites(Convert.ToInt32(e.Value)); trvSite.DataBind(); trvSite.UnselectAllNodes(); cboSite.Text = string.Empty; cboSite.SelectedIndex = -1; PopulateSiteDependants(); }protected void PopulateSiteDependants() { RadTreeView trvSite = new RadTreeView(); RadComboBox cboSite = (RadComboBox)fvIncidentEdit.FindControl("cboSite"); if (cboSite.Controls[2].FindControl("trvSite") != null) { trvSite = ((RadTreeView)cboSite.Controls[2].FindControl("trvSite")); RadTreeView trvLocation = new RadTreeView(); RadComboBox cboLocation = (RadComboBox)fvIncidentEdit.FindControl("cboLocation"); if (cboLocation.Controls[2].FindControl("trvLocation") != null) { if (trvSite.SelectedNode != null) { trvLocation = ((RadTreeView)cboLocation.Controls[2].FindControl("trvLocation")); trvLocation.DataSource = Models.Location.LoadActiveLocations(Convert.ToInt32(trvSite.SelectedNode.Value)); trvLocation.DataBind(); trvLocation.UnselectAllNodes(); } else { trvLocation.DataSource = null; } cboLocation.Text = string.Empty; cboLocation.SelectedIndex = -1; } RadTreeView trvDepartment = new RadTreeView(); RadComboBox cboDepartment = (RadComboBox)fvIncidentEdit.FindControl("cboDepartment"); if (cboDepartment.Controls[2].FindControl("trvDepartment") != null) { if (trvSite.SelectedNode != null) { trvDepartment = ((RadTreeView)cboDepartment.Controls[2].FindControl("trvDepartment")); trvDepartment.DataSource = Models.Department.LoadActiveDepartments(Convert.ToInt32(trvSite.SelectedNode.Value)); trvDepartment.DataBind(); trvDepartment.UnselectAllNodes(); } else { trvDepartment.DataSource = null; } cboDepartment.Text = string.Empty; cboDepartment.SelectedIndex = -1; } } LoadCategories(); } protected void LoadCategories() { RadTreeView trvDepartment = new RadTreeView(); RadComboBox cboDepartment = (RadComboBox)fvIncidentEdit.FindControl("cboDepartment"); if (cboDepartment.Controls[2].FindControl("trvDepartment") != null) { trvDepartment = ((RadTreeView)cboDepartment.Controls[2].FindControl("trvDepartment")); RadComboBox cboCategory = (RadComboBox)fvIncidentEdit.FindControl("cboCategory"); RadTreeView trvCategory = (RadTreeView)cboCategory.Controls[2].FindControl("trvCategory"); if (trvDepartment.SelectedNode != null) { trvCategory.DataSource = Models.QuestionCategoryNode.LoadActiveQuestionCategoryNodes(Convert.ToInt32(trvDepartment.SelectedNode.Value)); } else { trvCategory.DataSource =Models.QuestionCategoryNode.LoadActiveQuestionCategoryNodes(); } trvCategory.DataBind(); trvCategory.UnselectAllNodes(); cboCategory.Text = string.Empty; cboCategory.SelectedIndex = -1; } }
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script type="text/javascript"> function ShowInsertForm() { window.radopen("newrp.aspx", "RW_RP"); return false; } function refreshGrid(arg) { if (!arg) { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind"); } else { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate"); } } function RowDblClick(sender, eventArgs) { window.radopen("newrp.aspx?nbid=" + eventArgs.getDataKeyValue("nbid") + "&cocc=" + eventArgs.getDataKeyValue("cocc") + "&tm=" + eventArgs.getDataKeyValue("teammate") + "&dot7=" + eventArgs.getDataKeyValue("dot7"), "RW_RP"); } </script></telerik:RadCodeBlock><telerik:RadGrid ID="RG_RP" runat="server" CellSpacing="0" GridLines="None" style="margin:10px"> <MasterTableView AutoGenerateColumns="False" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" AlternatingItemStyle-HorizontalAlign="Center" CommandItemDisplay="Top" ClientDataKeyNames="nbid, cocc, teammate, dot7"> <GroupByExpressions> <telerik:GridGroupByExpression> <SelectFields> <telerik:GridGroupByField FieldName="Teammate" FieldAlias="Teammate" HeaderValueSeparator=": " /> </SelectFields> <GroupByFields> <telerik:GridGroupByField FieldName="Teammate" FieldAlias="Teammate" SortOrder="Ascending" /> </GroupByFields> </telerik:GridGroupByExpression> </GroupByExpressions> <Columns>... SOME COLUMNS ... </Columns> <EditFormSettings> <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn> </EditFormSettings> <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Add new preferences"></CommandItemSettings> <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle> <CommandItemTemplate> <div style="padding:5px 0px 5px 10px">Double click a row to add a preference for that Teammate</div> </CommandItemTemplate> </MasterTableView> <ClientSettings> <ClientEvents OnRowDblClick="RowDblClick" /> </ClientSettings> <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle> <FilterMenu EnableImageSprites="False"></FilterMenu></telerik:RadGrid>I am having difficulty getting the group by Footer Text to have say Subtotal for the groups and then an actual total for everything
I have tried implementing suggestions listed in other forums but none of them seem to work. Any help would be greatly appreciated.
Example what I am trying for is
Type: Type 1 - Water Quality
Data $5
Data $6
Data $4
--Footer Type 1 - Water Quality total sites: 3 $15
Type: Type 2 - Research
Data $10
Data $20
Data $20
--Footer Type 2 - Research total Sites sites: 3 $50
Total sites: 6 $65
FRONT END
<telerik:RadGrid ID="rgSite" runat="server" AllowSorting="True" Skin="Silk" OnNeedDataSource="rgSite_NeedDataSource" EnableLinqExpressions="false" OnPreRender="rgSite_PreRender" AutoGenerateColumns="False" AlternatingItemStyle-BackColor="White" Width="1298px" OnUpdateCommand="rgSite_UpdateCommand" OnInsertCommand="rgSite_InsertCommand"> <MasterTableView CommandItemDisplay="Top" ShowFooter="true" ShowGroupFooter="true" DataKeyNames="details_site_id"> <EditFormSettings PopUpSettings-Modal="false" UserControlName="controls/FundedSites.ascx" EditFormType="WebUserControl"/> <CommandItemSettings ShowRefreshButton="false" ShowAddNewRecordButton="false" addnewrecordtext="Add a Site"/> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" Visible="false" UniqueName="Edit"/> <telerik:GridBoundColumn DataField="site_no" SortExpression="site_no" AllowSorting="true" UniqueName="site_no" visible="false"/> <telerik:GridTemplateColumn DataField="site_no_nm" SortExpression="site_no_nm" UniqueName="site_no_nm" HeaderText="Site Number" ItemStyle-BorderStyle="Solid" ItemStyle-Bordercolor="Silver" ItemStyle-BorderWidth="0.25" Aggregate="CountDistinct" FooterText="Total Funded Sites: "> <ItemTemplate> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# string.Format("site.aspx?org_cd={0}&cust_id={1}&agmt_id={2}&site_no={3}",org_cd,cust_id,agmt_id,ProcessMyDataItem(Eval("site_no"))) %>' Text='<%# ProcessMyDataItem(Eval("site_no_nm")) %>'/> <asp:HiddenField runat="server" ID="hfCollectionUnits" Visible="false" Value='<%# ProcessMyDataItem(Eval("data_collection")) %>'/> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn DataField="collection_cd" SortExpression="collection_cd" UniqueName="collection_cd" HeaderText="Code" ItemStyle-BorderStyle="Solid" ItemStyle-Bordercolor="Silver" ItemStyle-BorderWidth="0.25"> <ItemTemplate> <a title='<%# ProcessMyDataItem(Eval("collection_desc")) %>' style="color:Black;text-decoration:none;"> <%# ProcessMyDataItem(Eval("collection_cd"))%> </a> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="collection_units" SortExpression="collection_units" AllowSorting="true" UniqueName="collection_units" HeaderText="Units" ItemStyle-BorderStyle="Solid" ItemStyle-Bordercolor="Silver" ItemStyle-BorderWidth="0.25" ColumnEditorID="ceUnit"/> <telerik:GridBoundColumn DataField="diff_factor" SortExpression="diff_factor" AllowSorting="true" UniqueName="diff_factor" HeaderText="Diff. Factor" ItemStyle-BorderStyle="Solid" ItemStyle-Bordercolor="Silver" ItemStyle-BorderWidth="0.25" ColumnEditorID="ceUnit"/> <%--<telerik:GridBoundColumn DataField="data_collection" SortExpression="data_collection" UniqueName="data_collection" HeaderText="Data Collection" Visible="false" ItemStyle-BorderStyle="Solid" ItemStyle-Bordercolor="Silver" ItemStyle-BorderWidth="0.25" />--%> <telerik:GridNumericColumn DataField="funding_usgs_cwp" SortExpression="funding_usgs_cwp" AllowSorting="true" UniqueName="funding_usgs_cwp" HeaderText="USGS CWP" DataFormatString="{0:c0}" DataType="System.Decimal" ItemStyle-BorderStyle="Solid" ItemStyle-Bordercolor="Silver" ItemStyle-BorderWidth="0.25" Aggregate="Sum" FooterAggregateFormatString="{0:c0}" ColumnEditorID="ceFunds"/> <telerik:GridNumericColumn DataField="funding_customer" SortExpression="funding_customer" AllowSorting="true" UniqueName="funding_customer" HeaderText="Customer" DataFormatString="{0:c0}" DataType="System.Decimal" ItemStyle-BorderStyle="Solid" ItemStyle-Bordercolor="Silver" ItemStyle-BorderWidth="0.25" Aggregate="Sum" FooterAggregateFormatString="{0:c0}" ColumnEditorID="ceFunds"/> <telerik:GridBoundColumn DataField="funding_total" SortExpression="funding_total" AllowSorting="true" UniqueName="total" HeaderText="Total" DataFormatString="{0:c0}" DataType="System.Decimal" ItemStyle-BorderStyle="Solid" ItemStyle-Bordercolor="Silver" ItemStyle-BorderWidth="0.25" Aggregate="Sum" FooterAggregateFormatString="{0:c0}" ReadOnly="true"/> <telerik:GridBoundColumn DataField="remarks" SortExpression="remarks" AllowSorting="true" UniqueName="remarks" HeaderText="Remarks" ItemStyle-BorderStyle="Solid" ItemStyle-Bordercolor="Silver" ItemStyle-BorderWidth="0.25" /> <telerik:GridButtonColumn ConfirmText="Delete this record?" ConfirmDialogType="RadWindow" confirmtitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" uniquename="Delete" Visible="false"/> </Columns> <GroupByExpressions> <telerik:GridGroupByExpression> <SelectFields> <telerik:GridGroupByField FieldName="data_collection" FieldAlias="Task"/> </SelectFields> <GroupByFields> <telerik:GridGroupByField FieldName="data_collection" /> </GroupByFields> </telerik:GridGroupByExpression> </GroupByExpressions> <ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> </MasterTableView></telerik:RadGrid>
CODE BEHIND
protected void rgSite_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
var fundingdb = new fundingdbDataContext();
rgSite.DataSource = fundingdb.SP_Funding_Agreement_Sites_Details(Convert.ToInt32(agmt_id),Convert.ToInt32(cust_id)).ToList();
}
//Removes Repeating values
protected void rgSite_PreRender(object sender, EventArgs e)
{
//The Row Index is the Row above the bottom row, walk up the Grid
for (int rowIndex = rgSite.Items.Count - 2; rowIndex >= 0; rowIndex += -1)
{
//The Current Row is the row index
GridDataItem row = rgSite.Items[rowIndex];
//The Previous Row is one below it
GridDataItem previousRow = rgSite.Items[rowIndex + 1];
//Grab the ItemTemplate Text values from the Hyperlink of the current and previous row and compare them.
if ((row["site_no"].FindControl("HyperLink1") as HyperLink).Text == (previousRow["site_no"].FindControl("HyperLink1") as HyperLink).Text && (row["site_no"].FindControl("hfCollectionUnits") as HiddenField).Value == (previousRow["site_no"].FindControl("hfCollectionUnits") as HiddenField).Value)
{
//If they are the same set the previous rows Text to blank
previousRow["site_no_nm"].Text = "";
}
}
}