Hello
I'm having a problem with grouping in the grid.
The data source is a List, the list itens contains another List, I want to group by the first item in this list (TestList[0].DescTest).
Putting the TestList[0].DescTest as DataField, the field is normally displayed, and can also be sorted, but when grouping the following error occurs:
Field definition is not valid. FieldName contains invalid characters: TestList[0].DescTest
I tried several other ways, but could not solve my problem.
I'm having a problem with grouping in the grid.
The data source is a List, the list itens contains another List, I want to group by the first item in this list (TestList[0].DescTest).
Putting the TestList[0].DescTest as DataField, the field is normally displayed, and can also be sorted, but when grouping the following error occurs:
Field definition is not valid. FieldName contains invalid characters: TestList[0].DescTest
I tried several other ways, but could not solve my problem.
public
class
TestInfo
{
public
int
IDTest {
get
;
set
; }
public
string
DescTest {
get
;
set
; }
public
List<TestInfo> TestList {
get
;
set
; }
}
<
telerik:RadGrid
ID
=
"rgd_grid"
runat
=
"server"
ShowGroupPanel
=
"true"
EnableHeaderContextMenu
=
"True"
EnableAJAX
=
"True"
OnNeedDataSource
=
"rgd_grid_NeedDataSource"
>
<
ClientSettings
ReorderColumnsOnClient
=
"true"
AllowGroupExpandCollapse
=
"true"
AllowDragToGroup
=
"true"
AllowColumnsReorder
=
"true"
AllowAutoScrollOnDragDrop
=
"false"
AllowExpandCollapse
=
"false"
>
<
Selecting
AllowRowSelect
=
"false"
/>
</
ClientSettings
>
<
GroupingSettings
ShowUnGroupButton
=
"True"
/>
<
MasterTableView
Summary
=
"RadGrid table"
Width
=
"100%"
DataKeyNames
=
"IDTest"
Name
=
"Test"
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"IDTest"
DataField
=
"IDTest"
HeaderText
=
"IDTest"
Groupable
=
"True"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"DescTest"
DataField
=
"DescTest"
HeaderText
=
"DescTest"
Groupable
=
"True"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"GroupTest"
DataField
=
"TestList[0].DescTest"
HeaderText
=
"GroupTest"
Groupable
=
"True"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
private
List<TestInfo> CreateDataSource()
{
List<TestInfo> list =
new
List<TestInfo>();
list.Add(
new
TestInfo());
list[0].IDTest = 1;
list[0].DescTest =
"Test 1"
;
list[0].TestList =
new
List<TestInfo>();
list[0].TestList.Add(
new
TestInfo());
list[0].TestList[0].DescTest =
"Group 1"
;
list.Add(
new
TestInfo());
list[1].IDTest = 2;
list[1].DescTest =
"Test 2"
;
list[1].TestList =
new
List<TestInfo>();
list[1].TestList.Add(
new
TestInfo());
list[1].TestList[0].DescTest =
"Group 2"
;
list.Add(
new
TestInfo());
list[2].IDTest = 3;
list[2].DescTest =
"Test 3"
;
list[2].TestList =
new
List<TestInfo>();
list[2].TestList.Add(
new
TestInfo());
list[2].TestList[0].DescTest =
"Group 3"
;
return
list;
}
protected
void
rgd_grid_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
rgd_grid.DataSource = CreateDataSource();
}