Hello
I am using a self referencing radgrid and declare it with
<MasterTableView DataKeyNames="ChildKey, ParentKey" AllowMultiColumnSorting="True" HierarchyLoadMode="Client>
<SelfHierarchySettings ParentKeyName="ParentKey" KeyName="ChildKey" />
<Columns>
...
...
</Columns>
</MasterTableView>
The problem is that the child keys show up twice -
1) Once as child elements of the parent
2) Second at the same level as parent
> Level
> Parent1
> Child1
> Child2
> Child1
> Child2
What am I doing wrong?
Thanks, Raka
I am using a self referencing radgrid and declare it with
<MasterTableView DataKeyNames="ChildKey, ParentKey" AllowMultiColumnSorting="True" HierarchyLoadMode="Client>
<SelfHierarchySettings ParentKeyName="ParentKey" KeyName="ChildKey" />
<Columns>
...
...
</Columns>
</MasterTableView>
The problem is that the child keys show up twice -
1) Once as child elements of the parent
2) Second at the same level as parent
> Level
> Parent1
> Child1
> Child2
> Child1
> Child2
What am I doing wrong?
Thanks, Raka
6 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 11 Jun 2013, 04:46 AM
Hi,
Please take a look into the sample code snippet I tried.
ASPX:
C#:
Please elaborate your scenario if it doesn't help.
Thanks.
Shinu.
Please take a look into the sample code snippet I tried.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
>
<
MasterTableView
AllowSorting
=
"true"
DataKeyNames
=
"Part, ProductID"
Width
=
"100%"
>
<
SelfHierarchySettings
ParentKeyName
=
"Part"
KeyName
=
"ProductID"
/>
</
MasterTableView
>
<
ClientSettings
AllowExpandCollapse
=
"true"
>
</
ClientSettings
>
</
telerik:RadGrid
>
C#:
protected
void
RadGrid1_NeedDataSource(
object
source, GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = GetDataTable(
"SELECT top 10* FROM [Order Details]"
);
}
public
DataTable GetDataTable(
string
query)
{
String ConnString = ConfigurationManager.ConnectionStrings[
"NorthwindConnectionString3"
].ConnectionString;
SqlDataAdapter adapter =
new
SqlDataAdapter();
DataTable myDataTable =
new
DataTable();
using
(SqlConnection conn =
new
SqlConnection(ConnString))
{
adapter.SelectCommand =
new
SqlCommand(query, conn);
adapter.Fill(myDataTable);
}
return
myDataTable;
}
Please elaborate your scenario if it doesn't help.
Thanks.
Shinu.
0
Raka
Top achievements
Rank 1
answered on 11 Jun 2013, 11:41 AM
Hi Shinu
Thanks much for the reply. The problem is that the first child is displayed correctly but the second level child (grandchild) is not.
When I add first child, I see something like
>Task1
>Person1
>Person2
So far so good...
But when I have Person1 reassign the task to someone else (Person3), that is where the problem is. Now what I see is this --
>Task1
>Person1
>Person3
>Person2
>Person3
It should only be
>Task1
>Person1
>Person3
>Person2
Thanks for your help.
Raka.
Thanks much for the reply. The problem is that the first child is displayed correctly but the second level child (grandchild) is not.
When I add first child, I see something like
>Task1
>Person1
>Person2
So far so good...
But when I have Person1 reassign the task to someone else (Person3), that is where the problem is. Now what I see is this --
>Task1
>Person1
>Person3
>Person2
>Person3
It should only be
>Task1
>Person1
>Person3
>Person2
Thanks for your help.
Raka.
0
Hi Raka,
I am not sure how your data table is populated and how is your data source relations are specified inside the same table. I would recommend you to review the following help article which elaborates more on this matter.
Regards,
Kostadin
Telerik
I am not sure how your data table is populated and how is your data source relations are specified inside the same table. I would recommend you to review the following help article which elaborates more on this matter.
Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Raka
Top achievements
Rank 1
answered on 14 Jun 2013, 03:01 PM
Hello Kostadin
Thanks for your reply. I have seen that article and from what I can see, I am following this example.
My table (AssignmentTable) has structure like --
TaskAssignmentId (Primary key)
Task AssignmentStatusId (Foreign key to Status table)
DeptId (Foreign key to Dept table)
UserId
ParentId (Foreign key to self (AssignmentTable) )
Comment
The grid is declared as
<MasterTableView DataKeyNames="TaskAssignmentId , ParentId " AllowMultiColumnSorting="True" HierarchyLoadMode="Client>
<SelfHierarchySettings ParentKeyName="ParentId " KeyName="TaskAssignmentId " />
<Columns>
...
...
</Columns>
</MasterTableView>
I create a view on this table and bind the grid to that view.
Does something stand out as wrong here?
Thanks for your reply. I have seen that article and from what I can see, I am following this example.
My table (AssignmentTable) has structure like --
TaskAssignmentId (Primary key)
Task AssignmentStatusId (Foreign key to Status table)
DeptId (Foreign key to Dept table)
UserId
ParentId (Foreign key to self (AssignmentTable) )
Comment
The grid is declared as
<MasterTableView DataKeyNames="TaskAssignmentId , ParentId " AllowMultiColumnSorting="True" HierarchyLoadMode="Client>
<SelfHierarchySettings ParentKeyName="ParentId " KeyName="TaskAssignmentId " />
<Columns>
...
...
</Columns>
</MasterTableView>
I create a view on this table and bind the grid to that view.
Does something stand out as wrong here?
0
Raka
Top achievements
Rank 1
answered on 17 Jun 2013, 04:45 PM
We fixed it by manually hiding the items that show up under the root by --
string temp = e.Item.ItemIndexHierarchical;
object pId = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ParentId"];
if (!temp.Contains(":") && pId != null)
{
e.Item.Display =
false;
return;
}
Still think that there must be a better way, but it gets us moving forward.
Thanks
Raka
0
Hello Raka,
I am afraid without runnable sample it will be hard to pinpoint the reason for that behavior. You database relation looks correct. You could try the first example in the previous provided documentation and check how it works.
Regards,
Kostadin
Telerik
I am afraid without runnable sample it will be hard to pinpoint the reason for that behavior. You database relation looks correct. You could try the first example in the previous provided documentation and check how it works.
Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.