Hi,
I have a routine that loops through the groupings and expands or collapses the group based on the maximum value of an ID in the grouped rows (esentially if there are grouped rows with the id expand, other wise collapse).
Here is the routine:
And I am adding text and formating to the grouped item in code at ItemDataBound:
My problem is that ghItem.AggregatesValues("LogID") always returns Nothing. If I specify a GroupHeaderTemplate delaritively then the SetExpandCollapse works fine. Unfortunately, I can't declare the GroupHeader this way because I want to be able to remove grouping with a button so the user can set up his own grouping by dragging headers to the group bar. If there is a GroupHeaderTemplate then an exception is thrown.
Can you see why ghItem.AggregatesValues("LogID") in SetExpandCollapse is alwys Nothing? Or can you tell me how to add and remove the GroupHeaderTemplate programmatically?
Thanks.
Charles
I have a routine that loops through the groupings and expands or collapses the group based on the maximum value of an ID in the grouped rows (esentially if there are grouped rows with the id expand, other wise collapse).
Here is the routine:
Sub SetExpandCollapse() Try For Each ghItem As GridGroupHeaderItem In rgCraigslistPostLog.MasterTableView.GetItems(GridItemType.GroupHeader) Dim MaxPostLogID As Int32 If ghItem.AggregatesValues("LogID") Is Nothing Then MaxPostLogID = 0 Else MaxPostLogID = ghItem.AggregatesValues("LogID") End If If MaxPostLogID = 0 Then ghItem.Expanded = False Else ghItem.Expanded = True End If Next Catch ex As Exception CraigslistPostingTool.DataAccess.LogError(ex, Request, GetCurrentMethod.Name, GroupID, AutoclickID) End Try End SubAnd I am adding text and formating to the grouped item in code at ItemDataBound:
Private Sub rgCraigslistPostLog_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles rgCraigslistPostLog.ItemDataBound Try If TypeOf e.Item Is GridGroupHeaderItem Then Dim item As GridGroupHeaderItem = CType(e.Item, GridGroupHeaderItem) Dim groupDataRow As DataRowView = CType(e.Item.DataItem, DataRowView) item.DataCell.Text = "<label style='font-weight:bold'>" + groupDataRow("Vehicle").ToString() + "'</label> " item.DataCell.Text += "<a href='#' onclick='LaunchPTpopup1(" + groupDataRow("ItemID").ToString() + ");return false;' >Post Vehicle</a>" End If If TypeOf e.Item Is Telerik.Web.UI.GridDataItem Then...My problem is that ghItem.AggregatesValues("LogID") always returns Nothing. If I specify a GroupHeaderTemplate delaritively then the SetExpandCollapse works fine. Unfortunately, I can't declare the GroupHeader this way because I want to be able to remove grouping with a button so the user can set up his own grouping by dragging headers to the group bar. If there is a GroupHeaderTemplate then an exception is thrown.
Can you see why ghItem.AggregatesValues("LogID") in SetExpandCollapse is alwys Nothing? Or can you tell me how to add and remove the GroupHeaderTemplate programmatically?
Thanks.
Charles
<telerik:RadGrid ID="rgCraigslistPostLog" ShowGroupPanel="true" AutoGenerateColumns="false" AllowSorting="true" DataSourceID="sqldsCLPostLog" ShowFooter="False" runat="server" GridLines="None" AllowPaging="true" PageSize="10" OnPreRender="RadGrid1_PreRender" Width="100%" > <MasterTableView ShowGroupFooter="false" CommandItemDisplay="None" EditMode="InPlace" PagerStyle-PageSizes="5,10,15,25,50,100"> <%--<CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false"></CommandItemSettings>--%> <%--<GroupHeaderTemplate> <asp:Label runat="server" ID="Label3" style="font-weight:bold" Text='<%# Eval("Vehicle") %>' ></asp:Label> <a href='#' onclick='<%# "javascript:LaunchPTpopup1("+ CStr(Eval("ItemID")) + ");return false;" %>' >Post Vehicle</a> </GroupHeaderTemplate>--%> <Columns> <telerik:GridBoundColumn HeaderText="ItemID" DataField="ItemID" Visible="false" Aggregate="Count"> <ItemStyle Width="50px" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText="Vehicle" DataField="vehicleWithStock" Visible="false" > <ItemStyle Width="300px" /> </telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderText="Post ID" SortExpression="PostLogID"> <ItemTemplate> <asp:Label ID="lblPostLogID" runat="server" Text=""></asp:Label> </ItemTemplate> <ItemStyle Width="50px" /> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Log Date" SortExpression="LogCreateDT"> <ItemTemplate> <asp:Label ID="lblLogDate" runat="server" Text=""></asp:Label> </ItemTemplate> <ItemStyle Width="100px" /> </telerik:GridTemplateColumn> <telerik:GridBoundColumn HeaderText="Profile" DataField="ProfileName" > <ItemStyle Width="80px" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText="Posted From" DataField="ClientIP" > <ItemStyle Width="70px" /> </telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderText="Post Location"> <ItemTemplate> <div style="padding:0px"> <asp:HyperLink ID="hlPostLocation" runat="server" Target="_blank" ToolTip="Click to View Listing Location." style="font:8pt" Text='<%# Eval("LocationName") %>' ></asp:HyperLink> </div> </ItemTemplate> <ItemStyle Width="150px" /> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Post Date" SortExpression="PostDate" > <ItemTemplate> <asp:Label ID="lblPostDate" runat="server" Text=""></asp:Label> </ItemTemplate> <ItemStyle HorizontalAlign="Center" Width="70px" /> </telerik:GridTemplateColumn> <telerik:GridBoundColumn HeaderText="PostLogID" DataField="PostLogID" Visible="false" Aggregate="Max"> </telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderText="Post Duration" SortExpression="PlannedDurationDays" > <ItemTemplate> <asp:DropDownList runat="server" ID="ddlDuration" CssClass="dropdownText" AutoPostBack="true" OnSelectedIndexChanged="ddlDuration_changed" > <asp:ListItem Text="0" Value="0"></asp:ListItem> <asp:ListItem Text="1" Value="1"></asp:ListItem> <asp:ListItem Text="2" Value="2"></asp:ListItem> <asp:ListItem Text="3" Value="3"></asp:ListItem> <asp:ListItem Text="4" Value="4"></asp:ListItem> <asp:ListItem Text="5" Value="5"></asp:ListItem> <asp:ListItem Text="6" Value="6"></asp:ListItem> <asp:ListItem Text="7" Value="7"></asp:ListItem> <asp:ListItem Text="8" Value="8"></asp:ListItem> <asp:ListItem Text="9" Value="9"></asp:ListItem> <asp:ListItem Text="10" Value="10"></asp:ListItem> <asp:ListItem Text="11" Value="11"></asp:ListItem> <asp:ListItem Text="12" Value="12"></asp:ListItem> <asp:ListItem Text="13" Value="13"></asp:ListItem> <asp:ListItem Text="14" Value="14"></asp:ListItem> <asp:ListItem Text="15" Value="15"></asp:ListItem> <asp:ListItem Text="16" Value="16"></asp:ListItem> <asp:ListItem Text="17" Value="17"></asp:ListItem> <asp:ListItem Text="18" Value="18"></asp:ListItem> <asp:ListItem Text="19" Value="19"></asp:ListItem> <asp:ListItem Text="20" Value="20"></asp:ListItem> <asp:ListItem Text="21" Value="21"></asp:ListItem> <asp:ListItem Text="22" Value="22"></asp:ListItem> <asp:ListItem Text="23" Value="23"></asp:ListItem> <asp:ListItem Text="24" Value="24"></asp:ListItem> <asp:ListItem Text="25" Value="25"></asp:ListItem> <asp:ListItem Text="26" Value="26"></asp:ListItem> <asp:ListItem Text="27" Value="27"></asp:ListItem> <asp:ListItem Text="28" Value="28"></asp:ListItem> <asp:ListItem Text="29" Value="29"></asp:ListItem> <asp:ListItem Text="30" Value="30"></asp:ListItem> </asp:DropDownList> </ItemTemplate> <ItemStyle HorizontalAlign="Center" Width="100px" /> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Scheduled Removal Date" SortExpression="PlannedRemovalDate"> <ItemTemplate> <asp:Label ID="lblPlannedRemovalDate" runat="server" Text=""></asp:Label> </ItemTemplate> <ItemStyle Width="100px" /> </telerik:GridTemplateColumn> <telerik:GridBoundColumn HeaderText="Days On Craigslist" DataField="DaysActive"> <ItemStyle HorizontalAlign="Center" Width="70px" /> </telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderText="Days Left" SortExpression="DaysLeft"> <ItemTemplate> <asp:Panel ID="panelDaysLeft" runat="server" width="100%" Height="20px" style="padding-top:0px"> <asp:Label ID="lblDaysLeft" runat="server" Text="" ></asp:Label> </asp:Panel> </ItemTemplate> <ItemStyle HorizontalAlign="Center" Width="70px" /> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="ClickThroughs" HeaderText="Total Clicks"> <ItemStyle HorizontalAlign="Center" Width="80px" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="UniqueClickThroughs" HeaderText="Unique Clicks"> <ItemStyle HorizontalAlign="Center" Width="80px" /> </telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderText="View Post<br />From Log"> <ItemTemplate> <div style="padding:0px"> <asp:HyperLink ID="hlViewPostHTML" runat="server" Target="_blank" ToolTip="Click to View the post with HTML from the log." style="font:8pt" >View (Log)</asp:HyperLink> </div> </ItemTemplate> <ItemStyle Width="120px" /> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="View Post<br />in Craigslist"> <ItemTemplate> <asp:HyperLink ID="hlViewPostInCL" runat="server" Target="_blank" ToolTip="Click to View the actual post in Craigslist." style="font:8pt" >View (in CL)</asp:HyperLink> <%--<asp:HyperLink ID="hlEditCLPostURL" runat="server" ToolTip="Edit post URL in Craigslist" style="font:8pt" Text="(Edit)" href="#"></asp:HyperLink>--%> </ItemTemplate> <ItemStyle Width="160px" /> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Post Status"> <ItemTemplate> <asp:DropDownList ID="ddlPostStatus" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlPostStatus_Changed" CssClass="dropdownText"> </asp:DropDownList> </ItemTemplate> <EditItemTemplate></EditItemTemplate> <ItemStyle HorizontalAlign="Center" Width="110px" /> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="PostRemovedDate" HeaderText="Actual Date Removed" DataFormatString="{0:d}"> <ItemStyle HorizontalAlign="Center" Width="90px" /> </telerik:GridBoundColumn> <telerik:GridTemplateColumn> <ItemTemplate> <asp:HyperLink ID="hlEditPostLog" runat="server" style="font:11px Verdana;" ToolTip="Add a new log item for this vehicle to document a Craigslist post.">Add Post Log</asp:HyperLink> <asp:LinkButton runat="server" ID="lbDeleteLog" Text="Delete" ToolTip="Delete this Log row and all information about the post." style="font:11px Verdana;" OnClick="lbDeleteLog_click" OnClientClick="return confirm('Delete this Post Log? Note: doing so will erase all info saved about the post. This DOES NOT remove the post from Craigslist.');"></asp:LinkButton> </ItemTemplate> <ItemStyle HorizontalAlign="Center" Width="120px" /> </telerik:GridTemplateColumn> </Columns> <GroupByExpressions> <telerik:GridGroupByExpression> <GroupByFields> <telerik:GridGroupByField FieldName="ItemID" FieldAlias="VehicleID" > </telerik:GridGroupByField> </GroupByFields> <SelectFields> <telerik:GridGroupByField FieldName="vehicleWithStock" FieldAlias="Vehicle"> </telerik:GridGroupByField> <telerik:GridGroupByField FieldName="PostLogID" FieldAlias="LogID" Aggregate="Max"> </telerik:GridGroupByField> </SelectFields> </telerik:GridGroupByExpression> </GroupByExpressions> </MasterTableView> <%--<ExportSettings ExportOnlyData="false" IgnorePaging="true"> <Excel Format="Biff"></Excel> </ExportSettings>--%> <ClientSettings AllowDragToGroup="true"> </ClientSettings> <GroupingSettings ShowUnGroupButton="true"></GroupingSettings></telerik:RadGrid><telerik:RadWindowManager ID="RadWindowManager1" runat="server"> <Windows> <telerik:RadWindow ID="UserListDialog" runat="server" Title="Editing record" Height="300px" Width="300px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true"> </telerik:RadWindow> </Windows></telerik:RadWindowManager>