Hello,
I am having a problem when I use GroupLoadMode="Client" and HierarchyLoadMode="Client" with a RadGrid. The problem is that when I expand a group, all of the group's row's detail tables expand as well.
Is there a setting to stop this or any way to work around this? Fetching the data in our real life application is costly so the client modes are the only acceptable ones for the scenario.
The markup looks like below and is being fed data from a dataset, also shown below.
Regards,
Fredrik Hult
I am having a problem when I use GroupLoadMode="Client" and HierarchyLoadMode="Client" with a RadGrid. The problem is that when I expand a group, all of the group's row's detail tables expand as well.
Is there a setting to stop this or any way to work around this? Fetching the data in our real life application is costly so the client modes are the only acceptable ones for the scenario.
The markup looks like below and is being fed data from a dataset, also shown below.
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
>
<
MasterTableView
DataMember
=
"Employee"
DataKeyNames
=
"ID"
GroupLoadMode
=
"Client"
HierarchyLoadMode
=
"Client"
GroupsDefaultExpanded
=
"false"
>
<
GroupByExpressions
>
<
telerik:GridGroupByExpression
>
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"Location"
/>
</
GroupByFields
>
<
SelectFields
>
<
telerik:GridGroupByField
FieldName
=
"Location"
/>
</
SelectFields
>
</
telerik:GridGroupByExpression
>
</
GroupByExpressions
>
<
DetailTables
>
<
telerik:GridTableView
DataMember
=
"EmployeeProperties"
DataKeyNames
=
"ID"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
MasterKeyField
=
"ID"
DetailKeyField
=
"EmployeeID"
/>
</
ParentTableRelation
>
</
telerik:GridTableView
>
</
DetailTables
>
</
MasterTableView
>
</
telerik:RadGrid
>
protected
override
void
OnInit(EventArgs e)
{
RadGrid1.NeedDataSource +=
new
Telerik.Web.UI.GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
RadGrid1.DetailTableDataBind +=
new
Telerik.Web.UI.GridDetailTableDataBindEventHandler(RadGrid1_DetailTableDataBind);
base
.OnInit(e);
}
void
RadGrid1_DetailTableDataBind(
object
source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
DataSet ds = GetDataSource();
e.DetailTableView.DataSource = ds;
}
void
RadGrid1_NeedDataSource(
object
source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
DataSet ds = GetDataSource();
RadGrid1.DataSource = ds;
}
private
DataSet GetDataSource()
{
DataSet ds =
new
DataSet();
DataTable employee = ds.Tables.Add(
"Employee"
);
DataTable employeeProperties = ds.Tables.Add(
"EmployeeProperties"
);
var empKey = employee.Columns.Add(
"ID"
,
typeof
(
int
));
employee.Columns.Add(
"FullName"
,
typeof
(
string
));
employee.Columns.Add(
"DepartmentID"
,
typeof
(
string
));
employee.Columns.Add(
"Location"
,
typeof
(
string
));
var empPKey = employeeProperties.Columns.Add(
"ID"
,
typeof
(
int
));
var empPFK = employeeProperties.Columns.Add(
"EmployeeID"
,
typeof
(
int
));
employeeProperties.Columns.Add(
"Title"
,
typeof
(
string
));
employeeProperties.Columns.Add(
"Value"
,
typeof
(
string
));
employee.PrimaryKey =
new
[] { empKey };
employeeProperties.PrimaryKey =
new
[] { empPKey };
ds.Relations.Add(
new
DataRelation(
"rel"
, empKey, empPFK));
employee.Rows.Add(
new
object
[] { 1,
"Scott Smith"
, 1,
"Sweden"
});
employee.Rows.Add(
new
object
[] { 2,
"Adam West"
, 1,
"Sweden"
});
employee.Rows.Add(
new
object
[] { 3,
"John Doe"
, 2,
"Norway"
});
employee.Rows.Add(
new
object
[] { 4,
"Sven Svensson"
, 2,
"Norway"
});
employee.Rows.Add(
new
object
[] { 5,
"Anders Andersson"
, 3,
"Finland"
});
employee.Rows.Add(
new
object
[] { 6,
"Jane Doe"
, 3,
"Finland"
});
employee.Rows.Add(
new
object
[] { 7,
"Stan Smith"
, 4,
"United States of America"
});
int
i = 0;
foreach
(DataRow emp
in
employee.Rows)
{
string
[] s = ((
string
)emp[
"FullName"
]).Split(
new
[] {
' '
});
employeeProperties.Rows.Add(
new
object
[] { ++i, (
int
)emp[
"ID"
],
"GivenName"
, s[0] });
employeeProperties.Rows.Add(
new
object
[] { ++i, (
int
)emp[
"ID"
],
"GivenName"
, s[1] });
}
return
ds;
}
Regards,
Fredrik Hult