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

how to show/hide detail tables based on click link,which is in parent detail table

4 Answers 227 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sd
Top achievements
Rank 1
Sd asked on 05 Sep 2012, 09:58 AM

I have grid like below.i have two links Aggregate Data ,Account Data in detail table.

 

When i click Aggregate Data link  "Type" detail table view should display and Account" detail table view should hide
When i click Account Data  link Account" detail table view should display and "Type" detail table view should hide

 how to show/hide type/account detail tables based on Aggregate Data link/ Account Data  link clicks  

telerik:RadGrid ID="grdResult" runat="server" Width="100%" AutoGenerateColumns="False"

 AllowPaging="True" Skin="DV" EnableEmbeddedSkins="false" PageSize="25" ExpandCollapseColumn-Display="false"

 ExpandCollapseColumn-Visible="false">

 <mastertableview width="100%" nomasterrecordstext="<%$ Resources:Generic,NoRecord %>"

 pagesize="25" allowcustompaging="true" name="SourceTable">

 <Columns>

 ------------------------

 

 

---------------------------------

 </Columns>

 <DetailTables>

 <telerik:GridTableView Name="Site" runat="server" AllowPaging="false" PageSize="25"

 ShowHeader="false" TableLayout="Auto">

<HeaderStyle BackColor="#d1d1d1" />

 <Columns>

 <telerik:GridBoundColumn HeaderText="" UniqueName="SiteName" DataField="SiteName"

ItemStyle-Width="100px" ItemStyle-CssClass="MasBGcolor">

 </telerik:GridBoundColumn>

 <telerik:GridTemplateColumn >

 <ItemTemplate>

 <asp:Label ID="lblDisplay" runat="server" Text="Display:" ></asp:Label>

 <asp:Label ID="lblAgrData" runat="server" Text="Aggregate Data" visible="false"></asp:Label>

 <asp:LinkButton ID="lnkAgrData" runat="server" CommandName="cmdAggrigate">Aggregate Data</asp:LinkButton>|

 <asp:LinkButton ID="lnkAccountData" runat="server" CommandName="cmdAccount">Account Data</asp:LinkButton>

 </ItemTemplate>

 </telerik:GridTemplateColumn>

 </Columns>

 <DetailTables>

 <telerik:GridTableView Name="Type" runat="server" AllowPaging="false" PageSize="25" ExpandCollapseColumn-Display="false"

 ExpandCollapseColumn-Visible="false" ShowHeader="false" TableLayout="Auto" >

 <HeaderStyle BackColor="#d1d1d1" />

 <Columns>

 <telerik:GridBoundColumn HeaderText="" DataField="TypeName" UniqueName="TypeName" ItemStyle-CssClass="MasBGcolor" >

 </telerik:GridBoundColumn>

 </Columns>

 <DetailTables>

 <telerik:GridTableView Name="Details" runat="server" AllowPaging="false" PageSize="25"

 ShowHeader="false" TableLayout="Auto" >

 <HeaderStyle BackColor="#d1d1d1" />

 <Columns>

 -----------------------

------------------------------

 

</Columns>

 </telerik:GridTableView>

 </DetailTables>

 </telerik:GridTableView>

 <telerik:GridTableView Name="Account" runat="server" AllowPaging="false" PageSize="25"

 ShowHeader="false" TableLayout="Auto">

 <HeaderStyle BackColor="#d1d1d1" />

 <Columns>

 <telerik:GridBoundColumn HeaderText="" UniqueName="AccountName" DataField="AccountName"

 ItemStyle-Width="100px" ItemStyle-CssClass="MasBGcolor">

 </telerik:GridBoundColumn>

 </Columns>

 <DetailTables>

 <telerik:GridTableView Name="AccountType" runat="server" AllowPaging="false" PageSize="25" ExpandCollapseColumn-Display="false"

 ExpandCollapseColumn-Visible="false" ShowHeader="false" TableLayout="Auto" >

 <HeaderStyle BackColor="#d1d1d1" />

 <Columns>

 <telerik:GridBoundColumn HeaderText="" DataField="TypeName" UniqueName="TypeName" ItemStyle-CssClass="MasBGcolor" >

</telerik:GridBoundColumn>

 </Columns>

 <DetailTables>

 <telerik:GridTableView Name="AccountDetails" runat="server" AllowPaging="false" PageSize="25"

 ShowHeader="false" TableLayout="Auto" >

 <HeaderStyle BackColor="#d1d1d1" />

 <Columns>

 --------------------
--------------------

 </Columns>

 </telerik:GridTableView>

 </DetailTables>

 </telerik:GridTableView>

 </DetailTables>

 </telerik:GridTableView>

 </DetailTables>

 </telerik:GridTableView>

 </DetailTables>

 </mastertableview>

 <clientsettings allowexpandcollapse="false" />

 </telerik:RadGrid>

 

4 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 07 Sep 2012, 11:57 AM
Hi,

You could achieve the requested functionality using the following demo:
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/twotablesatlevel/defaultcs.aspx

Put a condition and according to the clicked LinkButton set one of the detail views Visible=false.

I hope this will prove helpful.

Kind regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Sd
Top achievements
Rank 1
answered on 10 Sep 2012, 06:49 AM
Thanks for reply.
I had put condition  according to the clicked LinkButton in item command event. but when i make detail views Visible=false.ITs not going to invisible.
In item command i wrote like this:

 

 

If e.CommandName = "cmdAccount" Then

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

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

 
ElseIf
e.CommandName = "cmdAggrigate" Then

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

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

 End If

 

0
Eyup
Telerik team
answered on 13 Sep 2012, 06:13 AM
Hi Sd,

Please try the following approach:
  - declare a Name for your detail tables:
<telerik:GridTableView ... Name="Account">
  - then use this Name to distinguish which table view you need to hide:
string commandName = string.Empty;
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    if (e.CommandName == "cmdAccount" || e.CommandName == "cmdAggrigate")
    {
        commandName = e.CommandName;
        e.Item.Expanded = true;
    }
}
protected void RadGrid1_DetailTableDataBind(object sender, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
    if (commandName.IndexOf(e.DetailTableView.Name) >= 0)
    {
        e.DetailTableView.Visible = false;
    }
    else
    {
        e.DetailTableView.Visible = true;
    }
}

That should do the trick. Please give it a try and let me know about the result.

Regards,
Eyup
The Telerik Team
0
Sd
Top achievements
Rank 1
answered on 13 Sep 2012, 06:58 AM
thanks for the reply .Solution what you mentioned is not working.
I already fixed this issue by some other way.
for those links i gave command name="ExpandCollapse"

<asp:LinkButton ID="lnkAgrData" runat="server" CommandName="ExpandCollapse" CommandArgument="cmdAggrigate" >Aggregate Data</asp:LinkButton>|

 <asp:LinkButton ID="lnkAccountData" runat="server" CommandName="ExpandCollapse" CommandArgument="cmdAccount" >Account Data</asp:LinkButton>

 ___________________________________
I am handling  those commandarguments in item command

 Private Sub grdResult_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles grdResult.ItemCommand

 If e.CommandArgument = "cmdAccount" Then

 strCommandName = "cmdAccount"

 e.Item.Expanded = False

 ElseIf e.CommandArgument = "cmdAggrigate" Then

 strCommandName = "cmdAggrigate"

 e.Item.Expanded = False

 End If

 End Sub
in grdResult_DetailTableDataBind event based on strCommandName  binding the grid.and visible and invisible the detail tables.

Tags
Grid
Asked by
Sd
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Sd
Top achievements
Rank 1
Share this question
or