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

[Solved] Double Column for Hierarchy Each Row In RadGrid

6 Answers 349 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ajit
Top achievements
Rank 1
Ajit asked on 21 May 2009, 11:29 AM
I want to have two hierarchy columns for each row in a telerik radgrid....

if any solution found please give ...................

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 May 2009, 09:56 AM
Hi Ajit,

I am afraid whether I understood your question correctly. I hope you are trying to implement two expand/collapse column with RadGrid and you are having multiple detail tables. Then on clicking the first column show the first detail table and then using the second expand/collapse show the second detail table. If this is your requirement you may use the following approach.

ASPX:
 
     <MasterTableView AutoGenerateColumns="False" Name="Master" CellSpacing="-1" DataKeyNames="ProductID" 
                DataSourceID="SqlDataSource1"
                
                <Columns> 
                    <telerik:GridBoundColumn DataField="ProductID" DataType="System.Int32" HeaderText="ProductID" 
                        ReadOnly="True" SortExpression="ProductID" UniqueName="ProductID"
                    </telerik:GridBoundColumn> 
                     
                    <telerik:GridBoundColumn DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" 
                        UniqueName="ProductName"
                    </telerik:GridBoundColumn> 
                
                    <telerik:GridExpandColumn CommandName="ExpandDetail1" ></telerik:GridExpandColumn> 
                    <telerik:GridButtonColumn Text="Edit" CommandName="Edit" ></telerik:GridButtonColumn> 
                    <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn> 
                      <telerik:GridExpandColumn CommandName="ExpandDetail2" ></telerik:GridExpandColumn> 
                </Columns> 
                 <DetailTables> 
                   <telerik:GridTableView runat="server" Visible="false" AutoGenerateColumns="false"  Name="Detail1" AllowPaging="true" PageSize="5" DataSourceID="SqlDataSource2" > 
                     <Columns> 
                        <telerik:GridBoundColumn DataField="OrderName" HeaderText="OrderName" SortExpression="OrderName" 
                        UniqueName="OrderName"
                        </telerik:GridBoundColumn> 
                        <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn> 
                     </Columns> 
                   </telerik:GridTableView> 
                    
                   <telerik:GridTableView  runat="server" Visible="false" Name="Detail2" AutoGenerateColumns="false" AllowPaging="true" PageSize="5" DataSourceID="SqlDataSource3" > 
                       <Columns> 
                        <telerik:GridBoundColumn DataField="Status" HeaderText="Status" SortExpression="Status" 
                        UniqueName="Status"
                        </telerik:GridBoundColumn> 
                         
                     </Columns> 
                   </telerik:GridTableView> 
                 </DetailTables> 
               
            </MasterTableView> 

CS:
 
  protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "ExpandDetail1") 
        { 
            e.Item.Expanded = !e.Item.Expanded; 
            if (e.Item.Expanded) 
            { 
                GridDataItem item = (GridDataItem)e.Item; 
                GridTableView childtable = (GridTableView)item.ChildItem.OwnerTableView; 
                item.ChildItem.NestedTableViews[0].Visible = true
                item.ChildItem.NestedTableViews[1].Visible = false
            } 
        } 
        else if (e.CommandName == "ExpandDetail2") 
        { 
            e.Item.Expanded = !e.Item.Expanded; 
           
            if (e.Item.Expanded) 
            { 
                GridDataItem item = (GridDataItem)e.Item; 
                GridTableView childtable = (GridTableView)item.ChildItem.OwnerTableView; 
                item.ChildItem.NestedTableViews[0].Visible = false
                item.ChildItem.NestedTableViews[1].Visible = true
            } 
        } 
  } 


Thanks
Shinu
0
Ajit
Top achievements
Rank 1
answered on 22 May 2009, 02:58 PM
Thanks,

its work form me...

but,the default the autogenerated expandecollapse colums is always get visible which i don't want...to happen.

0
Shinu
Top achievements
Rank 2
answered on 25 May 2009, 04:57 AM
Hi Ajit,

Hide the Default Expand Collapse column using the following code snippet.

CS:
 
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        //to hide the Expand/Collapse column 
        RadGrid1.MasterTableView.GetColumn("ExpandColumn").Display = false
    } 


Regards
Shinu.
0
Ajit
Top achievements
Rank 1
answered on 25 May 2009, 02:22 PM
HI,

 as i have two detailview columns but clicking on first column image ,second column image also shows expanded image for.....second column can we prevent this...
0
Markus
Top achievements
Rank 1
answered on 30 May 2009, 01:37 PM
Hi,

I want to add different tooltips for both the arrows columns of the same row. 

Please help me how can I do this.

Thanks,
Dhananjay
0
Sebastian
Telerik team
answered on 01 Jun 2009, 07:16 AM
Hello Dhananjay,

How to define different expand/collapse tooltips for your columns you can see from this topic in the documentation:
http://www.telerik.com/help/aspnet-ajax/grdlocalizingtootips.html

Best,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Ajit
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ajit
Top achievements
Rank 1
Markus
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or