I have an interesting problem that I'm not sure I can solve with a RadGrid, but I thought I'd give it a shot. I have a strongly-typed list of objects which I would like to display in a hierarchical grid. I'm using the NeedDataSource event to set the DataSource property of the RadGrid to the list. In the master table, I'd like to list each distinct AcctNo, and in the detail grid I'd like to display SerialNo, and Amount. Basically, it's a grouping operation, but the following scenario prevents me (unless I've missed something) from using grouping expressions.
The column editor of AcctNo is a RadComboBox, which contains values and associated formatting. When displayed in a grid, the display text of the combo box ensures that the values are formatted correctly. However, the formatting is not done with a format string. The RadComboBox is actually bound to a secondary list of objects (different than the ones displayed in the grid), each of which has a property which explicitly defines what the display text should be based on the contents of the object. When I use grouping expressions, the value that is displayed in the grid for AcctNo is the raw value from the grid object instead of the formatted value from the combo box object, I assume because of the difference in structure. It appears that, when grouping, the cell which contains each AcctNo is no longer represented by the RadComboBox, but only by the raw value of the grid object.
If there is a way around this difficulty, please tell me what I can do. Otherwise, I thought about displaying the grid as a hierarchy instead of a grouped grid, where the master records would only contain AcctNo, and each detail grid would be those objects which have AcctNo equal to the master record value. However, I don't think I quite understand how this will work, since it appears that hierarchical grids assume a list-within-a-list object structure, whereas I only have a 1-dimensional list. Following is the code I have so far for my grid. It does not work, but, again, I'm not real sure of the syntax.
Any ideas would be greatly appreciated.
Thanks in advance!
The column editor of AcctNo is a RadComboBox, which contains values and associated formatting. When displayed in a grid, the display text of the combo box ensures that the values are formatted correctly. However, the formatting is not done with a format string. The RadComboBox is actually bound to a secondary list of objects (different than the ones displayed in the grid), each of which has a property which explicitly defines what the display text should be based on the contents of the object. When I use grouping expressions, the value that is displayed in the grid for AcctNo is the raw value from the grid object instead of the formatted value from the combo box object, I assume because of the difference in structure. It appears that, when grouping, the cell which contains each AcctNo is no longer represented by the RadComboBox, but only by the raw value of the grid object.
If there is a way around this difficulty, please tell me what I can do. Otherwise, I thought about displaying the grid as a hierarchy instead of a grouped grid, where the master records would only contain AcctNo, and each detail grid would be those objects which have AcctNo equal to the master record value. However, I don't think I quite understand how this will work, since it appears that hierarchical grids assume a list-within-a-list object structure, whereas I only have a 1-dimensional list. Following is the code I have so far for my grid. It does not work, but, again, I'm not real sure of the syntax.
<
telerik:RadGrid
ID
=
"grdPPExceptions"
runat
=
"server"
GridLines
=
"None"
AllowPaging
=
"True"
AllowAutomaticUpdates
=
"true"
AllowAutomaticDeletes
=
"false"
AllowAutomaticInserts
=
"false"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
AllowMultiRowEdit
=
"false"
>
<
MasterTableView
CommandItemDisplay
=
"none"
AllowSorting
=
"true"
TableLayout
=
"Fixed"
AllowMultiColumnSorting
=
"false"
EditMode
=
"InPlace"
AutoGenerateColumns
=
"false"
NoMasterRecordsText
=
"No Positive Pay exceptions today."
DataKeyNames
=
"AcctNo,ExceptionID"
>
<
Columns
>
<
telerik:GridDropDownColumn
DataField
=
"AcctNo"
HeaderText
=
"Account"
DataType
=
"System.Int64"
UniqueName
=
"AcctNo"
SortExpression
=
"AcctNo"
DataSourceID
=
"odsPPAccounts"
Visible
=
"false"
ListTextField
=
"DisplayNameAcct"
ListValueField
=
"FullAcctNo"
CurrentFilterFunction
=
"EqualTo"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"cboAcctNoFilter"
runat
=
"server"
DataSourceID
=
"odsPPAccounts"
DataTextField
=
"DisplayNameAcct"
DataValueField
=
"FullAcctNo"
AppendDataBoundItems
=
"true"
SelectedValue='<%# CType(Container, GridItem).OwnerTableView.GetColumn("AcctNo").CurrentFilterValue %>'
OnClientSelectedIndexChanged="cboAcctNoFilter2_SelectedIndexChanged" Width="140px">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"(No Filter)"
/>
</
Items
>
</
telerik:RadComboBox
>
</
FilterTemplate
>
<
HeaderStyle
Width
=
"160px"
HorizontalAlign
=
"Center"
/>
</
telerik:GridDropDownColumn
>
</
Columns
>
<
DetailTables
>
<
telerik:GridTableView
CommandItemDisplay
=
"None"
AllowSorting
=
"true"
TableLayout
=
"Fixed"
AllowMultiColumnSorting
=
"false"
EditMode
=
"InPlace"
AutoGenerateColumns
=
"false"
NoDetailRecordsText
=
"No Positive Pay exceptions for this account today."
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
MasterKeyField
=
"AcctNo"
DetailKeyField
=
"ExceptionID"
/>
</
ParentTableRelation
>
<
Columns
>
<
telerik:GridNumericColumn
DataField
=
"SerialNo"
HeaderText
=
"Serial No."
DataType
=
"System.Int32"
UniqueName
=
"SerialNo"
SortExpression
=
"SerialNo"
ColumnEditorID
=
"gceSerialNo"
AllowFiltering
=
"false"
>
<
HeaderStyle
Width
=
"90px"
HorizontalAlign
=
"Center"
/>
<
ItemStyle
HorizontalAlign
=
"Right"
/>
</
telerik:GridNumericColumn
>
<
telerik:GridNumericColumn
DataField
=
"Amount"
HeaderText
=
"Amount"
DataType
=
"System.Decimal"
UniqueName
=
"Amount"
SortExpression
=
"Amount"
ColumnEditorID
=
"gceAmount"
NumericType
=
"Currency"
AllowFiltering
=
"false"
>
<
HeaderStyle
Width
=
"90px"
HorizontalAlign
=
"Center"
/>
<
ItemStyle
HorizontalAlign
=
"Right"
/>
</
telerik:GridNumericColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
</
MasterTableView
>
</
telerik:RadGrid
>
Any ideas would be greatly appreciated.
Thanks in advance!