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

[Solved] Hide one of several nested tables at the same level

4 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul Leamy
Top achievements
Rank 1
Paul Leamy asked on 19 Jun 2008, 02:45 PM
I have two gridTemplatecolumns with linkbuttons that have the commands "File" and "Comments" in the parentGrid. There are two detailsTables inside the parentGrid. When a linkbutton is clicked I only wish to display one of the nested detailsTables. At the moment both are displaying. In the item command of the radgrid I have put the following code

If e.CommandName = "Files" Then

e.Item.OwnerTableView.DetailTables(0).Visible =

False

e.Item.OwnerTableView.DetailTables(1).Visible =

True

End If

If e.CommandName = "Comments" Then

e.Item.OwnerTableView.DetailTables(0).Visible =

True

e.Item.OwnerTableView.DetailTables(1).Visible =

False

End If

But this does not change the visibilty of the nested tables.
How can I show the nested table dependant on which linkbutton is clicked?

4 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 20 Jun 2008, 02:55 PM
Hi Paul,

Please try moving this piece of code in the PreRender event of Radgrid and see if it works there. You can use a boolean flag to indicate the command name and the DetailTables show/hide condition.

Greetings,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Princy
Top achievements
Rank 2
answered on 23 Jun 2008, 10:44 AM
Hi Paul,

Try it in the PreRender event as shown below.

CS:
  public static string strCommandName = "";   
    protected void RadGrid2_PreRender(object sender, EventArgs e)  
    {  
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items)  
        {  
            if (strCommandName == "Files")  
            {  
                //if (item.Expanded)  
                 RadGrid2.MasterTableView.DetailTables[0].Visible = false;  
                 RadGrid2.MasterTableView.DetailTables[1].Visible = true;  
                   
            }  
            else if (strCommandName == "Comments")  
            {  
                RadGrid2.MasterTableView.DetailTables[0].Visible = true;  
                RadGrid2.MasterTableView.DetailTables[1].Visible = false;  
 
            }  
             
 
        }  
          
    }  
 
 


Princy.
Thanks
Princy.
0
Paul Leamy
Top achievements
Rank 1
answered on 23 Jun 2008, 03:37 PM
Hi Guys this is my code . It still doesn't work. Is there another event after pre-render that sets the visibilty of detailsTables

Thanks

Paul


Private _commentsFlag As Boolean

Private _filesFlag As Boolean



Private Sub RadGridStatusHistory_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGridStatusHistory.PreRender

RadGridStatusHistory.MasterTableView.DetailTables(0).Visible = _filesFlag

RadGridStatusHistory.MasterTableView.DetailTables(1).Visible = _commentsFlag

End Sub

Private Sub RadGridStatusHistory_ItemCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles RadGridStatusHistory.ItemCommand

Dim item As Telerik.WebControls.GridDataItem

e.Item.Expanded =

Not e.Item.Expanded

If e.CommandName = "Files" Then

_filesFlag =

True

_commentsFlag =

False

End If

If e.CommandName = "Comments" Then

_commentsFlag =

True

_filesFlag =

False

End If

For Each item In e.Item.OwnerTableView.Items

If item.Expanded Then

If item.Expanded AndAlso Not item Is e.Item Then

item.Expanded =

False

End If

End If

Next item

End Sub

0
Daniel
Telerik team
answered on 25 Jun 2008, 11:13 AM
Hello Paul,

Actually it depends on your approach. You may also try on either PreRenderComplete or DetailTableDataBind events. Alternatively you could send us a working copy of your project via support ticket to be able to review it locally and help you accordigly.

Greetings,
Daniel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Paul Leamy
Top achievements
Rank 1
Answers by
Veli
Telerik team
Princy
Top achievements
Rank 2
Paul Leamy
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or