This is a migrated thread and some comments may be shown as answers.

SingleSelection Self-Referencing Hierarchy

3 Answers 26 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Abdulrahman Omran
Top achievements
Rank 1
Abdulrahman Omran asked on 13 Mar 2011, 11:54 PM
Hi,

I have a hierarchical grid of Tasks. Each parent row (task) has the possibility of having 0-* child rows (tasks). The depth of the grid is indefinite.

Currently the grid SelectionMode is set to single but the grid allows the selection of one parent and one child at a time. I want to restrict the user to only be able to select a single task at a time ( regardless of whether it's a parent or a child task). - refer to the attached image.


I'm adding the child table definitions on the Xaml file. This is the code snippet:

<telerik:RadGridView.ChildTableDefinitions>
   <
telerik:GridViewTableDefinition>
        <
telerik:GridViewTableDefinition.Relation>
             <
telerik:TableRelation IsSelfReference="True">
                 <
telerik:TableRelation.FieldNames>
                       <
telerik:FieldDescriptorNamePair ParentFieldDescriptorName="TaskId" ChildFieldDescriptorName="ParentTaskId"/>
                 </
telerik:TableRelation.FieldNames>
             </
telerik:TableRelation>
      </
telerik:GridViewTableDefinition.Relation>
   </
telerik:GridViewTableDefinition>
</
telerik:RadGridView.ChildTableDefinitions>


And I'm defining the child grid on the dataloading event:
  private void ProjectTasksGridView_DataLoading(object sender, GridViewDataLoadingEventArgs e)
        {
            GridViewDataControl dataControl = (GridViewDataControl)sender;
            if (dataControl.ParentRow != null)
            {
 
                dataControl.GridLinesVisibility = GridLinesVisibility.Vertical;
                dataControl.IsFilteringAllowed = false;
                dataControl.ShowGroupPanel = false;
                dataControl.SelectionMode = System.Windows.Controls.SelectionMode.Single;
                dataControl.AutoGenerateColumns = false;
                dataControl.CanUserFreezeColumns = false;
 
                dataControl.IsReadOnly = true;
              
                dataControl.RowLoaded += new EventHandler<RowLoadedEventArgs>(ProjectTasksGridView_RowLoaded);
                dataControl.SelectionChanged += this.ProjectTasksGridView_SelectionChanged;
          
                GridViewDataColumn column = new GridViewDataColumn();
                column.DataMemberBinding = new Binding("WbsId");
                column.Header = "WBS";
                dataControl.Columns.Add(column);
 
                column = new GridViewDataColumn();
                column.DataMemberBinding = new Binding("TaskName");
                                         .
                                         .
                                         .
 
}


Looking for a reasonable solution.

Kindest Regards,
Abdul

3 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 14 Mar 2011, 08:38 AM
Hello Abdulrahman Omran,

You may take a look at this forum thread for a reference. 

Greetings,
Maya
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Abdulrahman Omran
Top achievements
Rank 1
answered on 15 Mar 2011, 01:17 AM
Hi Maya,

Thank you for the reference. I will apply the solution and then mark the reply as an answer if it does what I expect.


Regards,
Abdul
0
Abdulrahman Omran
Top achievements
Rank 1
answered on 18 Mar 2011, 06:00 AM
Thank you Maya,
The solution you provided has given on how to solve my scenario.


Regards,
Abdul
Tags
GridView
Asked by
Abdulrahman Omran
Top achievements
Rank 1
Answers by
Maya
Telerik team
Abdulrahman Omran
Top achievements
Rank 1
Share this question
or