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

Using Multiple ExpandCollapse Buttons

2 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Troy
Top achievements
Rank 1
Troy asked on 31 Jan 2011, 04:54 PM
I have a row in a RadGrid that contains three buttons:

<asp:Button ID="Button1" CommandName="ExpandCollapse" CommandArgument="1" Text="Button 1" runat="server" />
<asp:Button ID="Button2" CommandName="ExpandCollapse" CommandArgument="2" Text="Button 2" runat="server" />
<asp:Button ID="Button3" CommandName="ExpandCollapse" CommandArgument="3" Text="Button 3" runat="server" />

In my code-behind, I have the following code:

protected void RadGrid_ItemCommand(object sender, GridCommandEventArgs e)
{
    if ((e.CommandName == RadGrid.ExpandCollapseCommandName) && !e.Item.Expanded)
    {
        // Do stuff here...
    }
}

When I click on a button for the first time, I have a NestedViewTemplate that gets shown. How do I keep the NestedViewTemplate open if I click a different button in the same row? For example, I click button 1 to open the NestedViewTemplate and then I click button 2 to keep the NestedViewTemplate open while showing different data.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 01 Feb 2011, 07:34 AM
Hello,


One suggestion to accomplish this is setting different CommandNames for buttons and explicitly expanding the item based on the CommandName set.

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == "button1" && !e.Item.Expanded)
    {
        e.Item.Expanded = true;
    }
      . . .
 }

Mark-up:
<telerik:GridTemplateColumn HeaderText="buttons">
          <ItemTemplate>
              <asp:Button ID="Button5" CommandName="button1" CommandArgument="1" Text="Button 1"
                  runat="server" />
                     .   .   .



-Shinu.
0
Troy
Top achievements
Rank 1
answered on 03 Feb 2011, 07:55 PM
That works. I found that e.Cancel = true also works. Thank you.

Tags
Grid
Asked by
Troy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Troy
Top achievements
Rank 1
Share this question
or