I have a RadGrid that uses a SqlDataSource and the column are auto-generated by the data source. Each column represents a date between a selectable date range. The grid works fine except if I want to use GridGroupByExpression. If that is enabled, I get an message stating (for example):
Column '2013-02-19' does not belong to table .
Column '2013-02-19' does not belong to table .
I'm not performing a postback and I don't have anything being called during Page Load or Init. The fields that are aggregated are whole integers.The columns displayed would be something like, 2013-02-19, 2013-02-20, 2013-20-21... again, this works fine if I don't use the grid group by expression and I can group manually... I'm trying to have the grouping by default.
Below is my ASPX:
<telerik:RadGrid ID="RG_SLASummary" runat="server" CellSpacing="0" DataSourceID="SDS_SLASummary" GridLines="None" ShowGroupPanel="True" style="margin:10px" ShowFooter="True" Height="750" OnColumnCreated="RG_SLASummary_ColumnCreated">
<ClientSettings AllowColumnsReorder="True" AllowDragToGroup="True" ReorderColumnsOnClient="True">
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<AlternatingItemStyle Width="100px" />
<GroupHeaderItemStyle Width="100px" />
<GroupingSettings RetainGroupFootersVisibility="true" />
<MasterTableView DataSourceID="SDS_SLASummary" ShowGroupFooter="true">
<GroupByExpressions>
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldName="Region" FieldAlias="Region" />
<telerik:GridGroupByField FieldName="Status" FieldAlias="Status" />
<telerik:GridGroupByField FieldName="Scheduler" FieldAlias="Scheduler" />
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="Region" />
<telerik:GridGroupByField FieldName="Status" />
<telerik:GridGroupByField FieldName="Scheduler" />
</GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
<SortExpressions>
<telerik:GridSortExpression FieldName="Region" SortOrder="Ascending" />
<telerik:GridSortExpression FieldName="Status" SortOrder="Ascending" />
<telerik:GridSortExpression FieldName="Scheduler" SortOrder="Ascending" />
</SortExpressions>
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"/>
</RowIndicatorColumn>
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"/>
<ItemStyle Width="20px" />
</ExpandCollapseColumn>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
<EditItemStyle Width="100px" />
<FilterItemStyle Width="100px" />
<ActiveItemStyle Width="100px" />
<ItemStyle Width="100px" />
<SelectedItemStyle Width="100px" />
<FilterMenu EnableImageSprites="False"></FilterMenu>
</telerik:RadGrid>
<asp:SqlDataSource ID="SDS_SLASummary" runat="server" ConnectionString="<%$ ConnectionStrings:CWFMO %>" SelectCommand="ESP_SchedulerSLASummary" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="RDP_StartDate" DbType="Date" Name="startdate" PropertyName="SelectedDate" />
<asp:ControlParameter ControlID="RDP_EndDate" DbType="Date" Name="enddate" PropertyName="SelectedDate" />
</SelectParameters>
</asp:SqlDataSource>
Below is my code behind:
protected void RG_SLASummary_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
if (e.Column is GridNumericColumn)
{
GridNumericColumn gridNumericColumn = (GridNumericColumn)e.Column;
gridNumericColumn.Aggregate = GridAggregateFunction.Sum;
}
}
<telerik:RadGrid ID="RG_SLASummary" runat="server" CellSpacing="0" DataSourceID="SDS_SLASummary" GridLines="None" ShowGroupPanel="True" style="margin:10px" ShowFooter="True" Height="750" OnColumnCreated="RG_SLASummary_ColumnCreated"> <ClientSettings AllowColumnsReorder="True" AllowDragToGroup="True" ReorderColumnsOnClient="True"> <Selecting AllowRowSelect="True" /> <Scrolling AllowScroll="True" UseStaticHeaders="True" /> </ClientSettings> <AlternatingItemStyle Width="100px" /> <GroupHeaderItemStyle Width="100px" /> <GroupingSettings RetainGroupFootersVisibility="true" /> <MasterTableView DataSourceID="SDS_SLASummary" ShowGroupFooter="true"> <GroupByExpressions> <telerik:GridGroupByExpression> <SelectFields> <telerik:GridGroupByField FieldName="Region" FieldAlias="Region" /> <telerik:GridGroupByField FieldName="Status" FieldAlias="Status" /> <telerik:GridGroupByField FieldName="Scheduler" FieldAlias="Scheduler" /> </SelectFields> <GroupByFields> <telerik:GridGroupByField FieldName="Region" /> <telerik:GridGroupByField FieldName="Status" /> <telerik:GridGroupByField FieldName="Scheduler" /> </GroupByFields> </telerik:GridGroupByExpression> </GroupByExpressions> <SortExpressions> <telerik:GridSortExpression FieldName="Region" SortOrder="Ascending" /> <telerik:GridSortExpression FieldName="Status" SortOrder="Ascending" /> <telerik:GridSortExpression FieldName="Scheduler" SortOrder="Ascending" /> </SortExpressions> <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings> <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"> <HeaderStyle Width="20px"/> </RowIndicatorColumn> <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"> <HeaderStyle Width="20px"/> <ItemStyle Width="20px" /> </ExpandCollapseColumn> <EditFormSettings> <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn> </EditFormSettings> </MasterTableView> <EditItemStyle Width="100px" /> <FilterItemStyle Width="100px" /> <ActiveItemStyle Width="100px" /> <ItemStyle Width="100px" /> <SelectedItemStyle Width="100px" /> <FilterMenu EnableImageSprites="False"></FilterMenu></telerik:RadGrid><asp:SqlDataSource ID="SDS_SLASummary" runat="server" ConnectionString="<%$ ConnectionStrings:CWFMO %>" SelectCommand="ESP_SchedulerSLASummary" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="RDP_StartDate" DbType="Date" Name="startdate" PropertyName="SelectedDate" /> <asp:ControlParameter ControlID="RDP_EndDate" DbType="Date" Name="enddate" PropertyName="SelectedDate" /> </SelectParameters></asp:SqlDataSource>protected void RG_SLASummary_ColumnCreated(object sender, GridColumnCreatedEventArgs e) { if (e.Column is GridNumericColumn) { GridNumericColumn gridNumericColumn = (GridNumericColumn)e.Column; gridNumericColumn.Aggregate = GridAggregateFunction.Sum; } }