This is a migrated thread and some comments may be shown as answers.
DetailTable ItemDataBound
1 Answer 96 Views
This is a migrated thread and some comments may be shown as answers.
Shehab
Top achievements
Rank 1
Shehab asked on 24 Jul 2008, 05:32 PM

Hi All,

I am building a grid with detailed table to show Departments and in the detailed table there are Persons and SubDepartments. I am trying to build another detailed table to show the Persons inside the SubDepartments, however I was the first Detailed table to have the expand button only if it is SubDepartments and not showing it when it is Persons inside the main Departments.
Here is what I have in the aspx;

<radG:RadGrid ID="rgDep" runat="server" AutoGenerateColumns="False" GridLines="None" Skin="WebBlue">  
    <MasterTableView DataKeyNames="ContactID" HierarchyLoadMode="ServerBind">  
        <Columns> 
          <radG:GridBoundColumn DataField="ContactID" Display="False" HeaderText="ContactID" ReadOnly="True"   
            UniqueName="ContactID">  
          </radG:GridBoundColumn> 
          <radG:GridBoundColumn DataField="Contact" HeaderText="Department" ReadOnly="True" UniqueName="Contact">  
            <ItemStyle Font-Bold="True" /> 
          </radG:GridBoundColumn> 
          <radG:GridBoundColumn DataField="Ext" HeaderText="Extension" ReadOnly="True" UniqueName="Ext">  
          </radG:GridBoundColumn> 
          <radG:GridBoundColumn DataField="Pager" HeaderText="Pager" UniqueName="Pager">  
          </radG:GridBoundColumn> 
          <radG:GridBoundColumn DataField="Office" HeaderText="Office" UniqueName="Office">  
          </radG:GridBoundColumn> 
          <radG:GridBoundColumn DataField="Fax" HeaderText="Fax" UniqueName="Fax">  
          </radG:GridBoundColumn> 
          <radG:GridBoundColumn DataField="IP" HeaderText="IP" UniqueName="IP">  
          </radG:GridBoundColumn>           
        </Columns> 
        <RowIndicatorColumn Visible="False">  
        <HeaderStyle Width="20px"></HeaderStyle> 
        </RowIndicatorColumn> 
        <ExpandCollapseColumn> 
            <HeaderStyle Width="19px"></HeaderStyle> 
        </ExpandCollapseColumn> 
        <DetailTables> 
            <radG:GridTableView runat="server" HierarchyLoadMode="Client" GroupLoadMode="Client" DataKeyNames="DepID, ContactID" HierarchyDefaultExpanded="True" Width="100%">  
                <RowIndicatorColumn Visible="False">  
                    <HeaderStyle Width="20px" /> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn Visible="False">  
                    <HeaderStyle Width="19px" /> 
                </ExpandCollapseColumn>              
                <Columns> 
                    <radG:GridBoundColumn DataField="ContactID" Display="False" HeaderText="ContactID" ReadOnly="True"   
                        UniqueName="ContactID">  
                    </radG:GridBoundColumn> 
                    <radG:GridBoundColumn DataField="ContactType" HeaderText="ContactType" UniqueName="ContactType">  
                    </radG:GridBoundColumn>                                      
                    <radG:GridBoundColumn DataField="DepID" Display="False" HeaderText="DepID" 
                        ReadOnly="True" UniqueName="DepID">  
                    </radG:GridBoundColumn> 
                    <radG:GridBoundColumn DataField="Contact" HeaderText="Contact" UniqueName="Contact1">  
                    </radG:GridBoundColumn> 
                    <radG:GridBoundColumn DataField="EXT" HeaderText="Ext" UniqueName="Ext1">  
                    </radG:GridBoundColumn> 
                    <radG:GridBoundColumn DataField="Pager" HeaderText="Pager" UniqueName="Pager1">  
                    </radG:GridBoundColumn> 
                    <radG:GridBoundColumn DataField="Office" HeaderText="Office" UniqueName="Office1">  
                    </radG:GridBoundColumn> 
                    <radG:GridBoundColumn DataField="Fax" HeaderText="Fax" UniqueName="Fax1">  
                    </radG:GridBoundColumn> 
                    <radG:GridBoundColumn DataField="IP" HeaderText="IP" UniqueName="IP1">  
                    </radG:GridBoundColumn> 
                </Columns> 
                <ParentTableRelation> 
                    <radG:GridRelationFields DetailKeyField="DepID" MasterKeyField="ContactID" /> 
                </ParentTableRelation> 
                  
                <DetailTables> 
                    <radG:GridTableView runat="server" HierarchyLoadMode="Client" GroupLoadMode="Client" DataKeyNames="DepID" HierarchyDefaultExpanded="True" Width="100%">  
                        <RowIndicatorColumn Visible="False">  
                            <HeaderStyle Width="20px" /> 
                        </RowIndicatorColumn> 
                        <ExpandCollapseColumn Visible="False">  
                            <HeaderStyle Width="19px" /> 
                        </ExpandCollapseColumn> 
                        <Columns> 
                            <radG:GridBoundColumn DataField="DepID" Display="False" HeaderText="DepID" 
                                ReadOnly="True" UniqueName="DepID">  
                            </radG:GridBoundColumn> 
                            <radG:GridBoundColumn DataField="Contact" HeaderText="Contact" UniqueName="Contact2">  
                            </radG:GridBoundColumn> 
                            <radG:GridBoundColumn DataField="EXT" HeaderText="Ext" UniqueName="Ext2">  
                            </radG:GridBoundColumn> 
                            <radG:GridBoundColumn DataField="Pager" HeaderText="Pager" UniqueName="Pager2">  
                            </radG:GridBoundColumn> 
                            <radG:GridBoundColumn DataField="Office" HeaderText="Office" UniqueName="Office2">  
                            </radG:GridBoundColumn> 
                            <radG:GridBoundColumn DataField="Fax" HeaderText="Fax" UniqueName="Fax2">  
                            </radG:GridBoundColumn> 
                            <radG:GridBoundColumn DataField="IP" HeaderText="IP" UniqueName="IP2">  
                            </radG:GridBoundColumn> 
                        </Columns> 
                        <ParentTableRelation> 
                            <radG:GridRelationFields DetailKeyField="DepID" MasterKeyField="ContactID" /> 
                        </ParentTableRelation> 
                    </radG:GridTableView>              
                </DetailTables>      
                  
            </radG:GridTableView>              
        </DetailTables>       
    </MasterTableView>      
    <ClientSettings> 
        <Selecting AllowRowSelect="True" /> 
    </ClientSettings> 
</radG:RadGrid> 
It looks big but really it is not.
I am thinking to do this in the Detailed Table ItemDataBound, I just don't know how to pull the values to verify if it persons or subDepartments.

Thanks for all the help,
Shehab

1 Answer, 1 is accepted

Sort by
0
Accepted
Sebastian
Telerik team
answered on 28 Jul 2008, 12:40 PM
Hi Shehab,

How to hide the expand/collapse images in parent records when there is no child table to be displayed you can learn from the following article in the RadGrid for ASP.NET AJAX documentation. Feel free to modify the logic to meet your additional requirements for hierarchy presentation.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Shehab
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or