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

[Solved] Hierarchical Grid - Changing parent record based on child record choice

2 Answers 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bruce
Top achievements
Rank 1
Bruce asked on 07 Oct 2009, 04:13 PM
Hi all

I have an interesting issue I hope someone has an answer for.

I have a situation where I have two types of records, Full and Split. A full record may have from 0 to 3 split records. I want to display the full records and the splits in a detail table under the associated full record. That part is easy.

Here is the fun part...
According to the business rules:
1) If a full record is assigned, then the associated splits should be unavailble for assignment
2) If a split record is selected, then the parent full record should be unavailable for assignment.

I think I can accomplish rule #1 when databinding the detail table. I need to check to see that a person has been assigned to the full record. If so, I can either prevent the detailtabledatabind entirely, or disable the assign button for each detail record.

I am unsure, however, as to how to approach rule #2. Is there a way to get at the parent record when doing some sort of ItemDataBound on the detail table? That way I can see if a detail record has been assigned and turn off the assign button in the parent record.

Thanks for any and all help!
Bruce

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Oct 2009, 07:57 AM
Hello Bruce,

You can set the Name property for your detailtable of your grid. Then in the ItemDataBound event of the grid, you can check for the Name of the ownertableview and access the Parent record as shown in the code below:
aspx:
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" OnItemDataBound="RadGrid1_ItemDataBound">   
       <MasterTableView Name="Master" DataSourceID="SqlDataSource1">  
              <DetailTables>  
                    <telerik:GridTableView DataSourceID="SqlDataSource2" Name="Detail" runat="server">                   

c#:
 protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Detail"// to check for the detail table 
        { 
            GridDataItem childItem = (GridDataItem)e.Item; 
            GridDataItem parentItem = childItem.OwnerTableView.ParentItem;// to access parent row 
         
           //if(button in child row is unassigned)    
            //{ 
               // disable the parent row button 
           // }           
         
        } 
    } 

Hope this helps..
Princy.
0
Bruce
Top achievements
Rank 1
answered on 13 Oct 2009, 02:13 AM
So far so good, but there is only one wrinkle.

When I have a detail record with a certain value, I want the selection of associated master record unavailable. This works fine when the row is expanded, but it doesn't work when the grid is collapsed.

Is there any way to prevent the selection of a master record based on a detail record while the grid is collapsed?

I have tried the HierarchyLoadMode in all three values and really haven't noticed a difference in functionality. I though ServerBind would give me all the records without having to expand.

Thanks,
Bruce
Tags
Grid
Asked by
Bruce
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Bruce
Top achievements
Rank 1
Share this question
or