I have a Radgrid nested two levels, parent/child. When loading the grid I get all values in the parent grid when I just want distinct values on the parent.
<
telerik:RadGrid
RenderMode
=
"Lightweight"
ID
=
"grdChartofAccounts"
runat
=
"server"
AutoGenerateColumns
=
"false"
AllowSorting
=
"true"
AllowMultiRowSelection
=
"false"
OnNeedDataSource
=
"grdChartofAccounts_NeedDataSource"
>
<
MasterTableView
DataKeyNames
=
"JobID"
CommandItemDisplay
=
"Bottom"
>
<
DetailTables
>
<
telerik:GridTableView
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"JobID"
MasterKeyField
=
"JobID"
/>
</
ParentTableRelation
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"Task"
UniqueName
=
"Task"
DataField
=
"TaskID_Job"
/>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"Job"
UniqueName
=
"Job"
DataField
=
"JobID"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
protected
void
grdChartofAccounts_NeedDataSource(
object
sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
List<tasks> taskList =
new
List<tasks>();
for
(
int
i = 1; i <= 5; i++)
for
(
int
x = 1; x <= 5; x++)
{
tasks task =
new
tasks();
task.JobID = i;
task.TaskID = x;
taskList.Add(task);
}
DataTable dt =
new
DataTable();
dt.Columns.Add(
"JobID"
);
dt.Columns.Add(
"TaskID_Job"
);
foreach
(tasks task
in
taskList)
{
DataRow dr = dt.NewRow();
dr[
"JobID"
] = task.JobID.ToString();
dr[
"TaskID_Job"
] = task.TaskID;
dt.Rows.Add(dr);
}
this
.grdChartofAccounts.DataSource = dt;
}
I've attached two images of my existing output and my desired output.