I have the following RadGrid:
And my NeedDataSource:
ReportCylinderFacilityUsage is a stored procedure. One of the columns it returns is CylinderType
What I'd like to do is group by CylinderType and have the Count for each type of Cylinder displayed in the header.
When I have the following set up in the GroupBy Expressions:
I get an error: FieldName contains invalid characters: count(CylinderType)
if I put the Aggregate on the SelectField then I get the error: A column named "CylinderType" already belongs to this datatable.
Thanks,
Jason
<
telerik:RadGrid
ID
=
"uxFacilityUsage"
runat
=
"server"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
GridLines
=
"None"
onneeddatasource
=
"uxFacilityUsage_NeedDataSource"
ShowGroupPanel
=
"True"
onitemdatabound
=
"uxFacilityUsage_ItemDataBound"
onitemcommand
=
"uxFacilityUsage_ItemCommand"
AllowPaging
=
"True"
PageSize
=
"20"
AllowFilteringByColumn
=
"True"
ongroupschanging
=
"uxFacilityUsage_GroupsChanging"
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
></
HeaderContextMenu
>
<
GroupPanel
Text
=
"Drag a column header and drop it here to group by that column."
></
GroupPanel
>
<
AlternatingItemStyle
CssClass
=
"AlternatingRowStyle"
></
AlternatingItemStyle
>
<
PagerStyle
Mode
=
"NextPrevNumericAndAdvanced"
></
PagerStyle
>
<
ExportSettings
>
<
Pdf
PageLeftMargin
=
"0.5in"
PageRightMargin
=
"0.5in"
/>
</
ExportSettings
>
<
MasterTableView
CommandItemDisplay
=
"Top"
IsFilterItemExpanded
=
"false"
>
<
SortExpressions
>
<
telerik:GridSortExpression
FieldName
=
"StartDate"
SortOrder
=
"Descending"
/>
</
SortExpressions
>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
ShowAddNewRecordButton
=
"False"
ShowExportToPdfButton
=
"True"
></
CommandItemSettings
>
<
GroupByExpressions
>
<
telerik:GridGroupByExpression
>
<
SelectFields
>
<
telerik:GridGroupByField
FieldName
=
"CylinderType"
Aggregate
=
"Count"
/>
</
SelectFields
>
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"CylinderType"
FormatString
=
"{0:0}"
/>
</
GroupByFields
>
</
telerik:GridGroupByExpression
>
</
GroupByExpressions
>
<
RowIndicatorColumn
FilterControlAltText
=
"Filter RowIndicator column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
FilterControlAltText
=
"Filter ExpandColumn column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"LotNumber"
FilterControlAltText
=
"Filter LotNumber column"
HeaderText
=
"LotNumber"
SortExpression
=
"LotNumber"
UniqueName
=
"LotNumber"
>
<
HeaderStyle
Width
=
"150px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CylinderType"
FilterControlAltText
=
"Filter CylinderType column"
HeaderText
=
"Cylinder Type"
SortExpression
=
"CylinderType"
UniqueName
=
"CylinderType"
>
<
HeaderStyle
Width
=
"100px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"GasType"
FilterControlAltText
=
"Filter GasType column"
HeaderText
=
"Gas Type"
SortExpression
=
"GasType"
UniqueName
=
"GasType"
>
<
HeaderStyle
Width
=
"100px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Facility"
FilterControlAltText
=
"Filter Facility column"
HeaderText
=
"Facility"
SortExpression
=
"Facility"
UniqueName
=
"Facility"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"StartDate"
DataType
=
"System.DateTime"
FilterControlAltText
=
"Filter StartDate column"
HeaderText
=
"Start Date"
SortExpression
=
"StartDate"
UniqueName
=
"StartDate"
>
<
HeaderStyle
Width
=
"150px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"PatientName"
FilterControlAltText
=
"Filter PatientName column"
HeaderText
=
"Patient"
ReadOnly
=
"True"
SortExpression
=
"PatientName"
UniqueName
=
"PatientName"
>
<
HeaderStyle
Width
=
"120px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"PayerType"
FilterControlAltText
=
"Filter PatientName column"
HeaderText
=
"Payer Type"
ReadOnly
=
"True"
SortExpression
=
"PayerType"
UniqueName
=
"PayerType"
>
<
HeaderStyle
Width
=
"100px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"RoomNumber"
FilterControlAltText
=
"Filter RoomNumber column"
HeaderText
=
"Room"
SortExpression
=
"RoomNumber"
UniqueName
=
"RoomNumber"
>
<
HeaderStyle
Width
=
"50px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"BedAssignment"
FilterControlAltText
=
"Filter BedAssignment column"
HeaderText
=
"Bed"
SortExpression
=
"BedAssignment"
UniqueName
=
"BedAssignment"
>
<
HeaderStyle
Width
=
"100px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Location"
FilterControlAltText
=
"Filter Location column"
HeaderText
=
"Location"
SortExpression
=
"Location"
UniqueName
=
"Location"
>
<
HeaderStyle
Width
=
"150px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"FacilityUsername"
FilterControlAltText
=
"Filter FacilityUsername column"
HeaderText
=
"Assigned By"
ReadOnly
=
"True"
SortExpression
=
"FacilityUsername"
UniqueName
=
"FacilityUsername"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
></
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
GroupingSettings
ShowUnGroupButton
=
"True"
></
GroupingSettings
>
<
ClientSettings
AllowDragToGroup
=
"True"
>
<
Resizing
AllowColumnResize
=
"True"
EnableRealTimeResize
=
"True"
></
Resizing
>
</
ClientSettings
>
<
FilterMenu
EnableImageSprites
=
"False"
></
FilterMenu
>
</
telerik:RadGrid
>
And my NeedDataSource:
using
(var context =
new
DataContext(SqlHelper.NewConnection))
{
var results = context.ReportCylinderFacilityUsage(Master.FacilitySelection.SelectedValue);
uxFacilityUsage.DataSource = results.ToList();
}
ReportCylinderFacilityUsage is a stored procedure. One of the columns it returns is CylinderType
What I'd like to do is group by CylinderType and have the Count for each type of Cylinder displayed in the header.
When I have the following set up in the GroupBy Expressions:
<
telerik:GridGroupByExpression
>
<
SelectFields
>
<
telerik:GridGroupByField
FieldName
=
"CylinderType"
/>
</
SelectFields
>
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"CylinderType"
Aggregate
=
"Count"
/>
</
GroupByFields
>
</telerik:GridGroupByExpression>
if I put the Aggregate on the SelectField then I get the error: A column named "CylinderType" already belongs to this datatable.
Thanks,
Jason