Control Events in Accordion

Rate It (1)

Last post 03-07-2008 5:02 PM by hintzen. 19 replies.

Sort Posts:

  • Control Events in Accordion

    11-21-2006, 1:20 PM
    • Loading...
    • larrytee
    • Joined on 11-21-2006, 6:01 PM
    • Posts 1

    I have an accordion control which contains several panes each containing a GridView (by using ConentTemplate).  I would like to give the user the ability to edit GridView  items inline. The problem is that I must click twice to put the item into edit mode.  I have seen other posts with similar problems but no definite solution.  Any help would be greatly appreciated. 

     

     

     

     
    1        <ajaxToolkit:Accordion ID="Accordion1" runat="server" HeaderCssClass="accordionHeader"
    2        ContentCssClass="accordionContent" SelectedIndex="0"
    3        AutoSize="None" FadeTransitions="false" FramesPerSecond="40" TransitionDuration="250" EnableViewState="true" >
    4    
    5      
    6        
    7          <HeaderTemplate><a class="accordionLink" id="accordionLink" href="" onclick="return false;"><%# ((Person)((DictionaryEntry)Container.DataItem).Key).FirstName + " " + ((Person)((DictionaryEntry)Container.DataItem).Key).LastName %></a></HeaderTemplate>            
    8    
    9        <ContentTemplate>
    10         
    11   
    12   
    13                   <asp:GridView EnableViewState="true" ID="GridViewOpen" OnRowUpdating="GridViewOpen_RowUpdating"  OnInit="GridViewOpen_Init"  OnRowEditing="GridViewOpen_RowEditing" OnRowCancelingEdit="GridViewOpen_RowCancelingEdit" OnSelectedIndexChanged="GridViewOpen_SelectedIndexChanged"    runat="server" DataSource="<%# ((DictionaryEntry)Container.DataItem).Value %> "
    14                   AutoGenerateColumns="false" AutoGenerateEditButton="true" AutoGenerateSelectButton="false" AllowSorting="true">
    15                   <Columns>
    16                       
    17                       
    18                       
    19                       <asp:TemplateField  HeaderText="MoNumber" SortExpression="MoNumber">
    20                           <EditItemTemplate>
    21                              <asp:TextBox ID="LabelEditMoNumber" runat="server" Text='<%# Bind("MoNumber") %>'></asp:TextBox> 
    22                           </EditItemTemplate>
    23                           <ItemTemplate>
    24                               <asp:Label ID="LabelViewMoNumber" runat="server" Text='<%# Bind("MoNumber") %>'></asp:Label>
    25                               
    26                           </ItemTemplate>
    27                       </asp:TemplateField>                                             
    28                       
    29   
    30                       
    31                       
    32                       <asp:TemplateField HeaderText="Location" SortExpression="LocationId">
    33                           <EditItemTemplate>
    34                               <asp:DropDownList runat="server" id="dataLocationId" DataSourceID="objDsLocationId" DataTextField="Name" DataValueField="LocationId" SelectedValue='<%# Bind("LocationId") %>'></asp:DropDownList>
    35                           </EditItemTemplate>
    36                           <ItemTemplate>
    37                               <asp:Label ID="Label2" runat="server" Text='<%# FindLocation(Eval("LocationId")) %>'></asp:Label>
    38                           </ItemTemplate>
    39                       </asp:TemplateField>
    40                       <asp:TemplateField HeaderText="Time (Hrs)">
    41                           <ItemTemplate>
    42                               <asp:Label ID="Label3" runat="server" Text='-'></asp:Label>
    43                           </ItemTemplate>
    44                       </asp:TemplateField>
    45   
    46                           
    47                                                 
    48                           
    49                   </Columns>
    50               </asp:GridView> 
    51   
    52       </ContentTemplate> 
    53   
    54       </ajaxToolkit:Accordion> 
    
     

     

     

     

  • Re: Control Events in Accordion

    11-28-2006, 9:25 PM
    • Loading...
    • jkresner
    • Joined on 11-13-2006, 3:52 AM
    • Posts 6
    I too have this problem with a normal LinkButton
  • Re: Control Events in Accordion

    12-07-2006, 4:44 PM
    • Loading...
    • brendalisa
    • Joined on 11-29-2006, 4:02 PM
    • Posts 40
    Same problem here too, and it's driving me bonkers :(
    Brenda
  • Re: Control Events in Accordion

    12-07-2006, 6:44 PM
    • Loading...
    • Benton
    • Joined on 06-13-2005, 4:57 PM
    • Posts 52
    I see you are not using panes inside the accordion. Is this because you only need one pane? I thought you'd need one pane for every GridView Confused
  • Re: Control Events in Accordion

    12-27-2006, 3:26 PM
    • Loading...
    • brendalisa
    • Joined on 11-29-2006, 4:02 PM
    • Posts 40
    In my project, I am using Panes and I'm still having issued.  All the Panes are being loaded dynamically though, which I need to do that way.  Any ideas out there?
    Brenda
  • The solution

    01-22-2007, 7:33 AM

    All I have the solution, it dosen't make sence but it solves the problem

    at the page Load create a pointer to the control for example

    Dim btn As Button = CType(Accordion1.Panes(0).FindControl("btnQuickSearch"), Button)

    Where btnQuickSearch is the id of the button

    Good Luck

  • Re: The solution

    01-24-2007, 11:17 AM
    • Loading...
    • sricci
    • Joined on 01-24-2007, 4:06 PM
    • Posts 4

    This seems like a common problem.

     The example above works for an accordion with only one pane.  However, if I do the same to try and initialize controls in the second, or third pane it doesn't work.  I can reference the controls in my code, however I still have to click a button twice to fire the event.

     Does anyone have any thoughts on how to avoid this?  Or, can I catch the accordion transition event (if there is one) and then initialize my controls for that pane in that event?

    This one has me stumped.

     

    Filed under: , ,
  • Re: The solution

    07-18-2007, 7:01 PM

     I'm having almost the exact same issue. I am creating what is essentially a datagrid-accordion where each line of the control is an accordion panel. I managed to get sorting and paging to work, but they are outside the actual accordion control. I can't make the controls inside the accordion pane to trigger their appropriate event. At one point I was able to have them fire on the second click, but after adding a command name and command argument to the buttons, they don't do that anymore.

    I would also like to be able to have a 'cancel' button that closes the panel, but nothing is working. The cancel button could be done with javascript, but no one seems to know how to do this. Are there no solutions to these problems? I don't want to have to make with a complicated work around where I have to create the buttons inside the accordions data bind event... its way more hassle than its worth.

    Thanks

     

  • Re: The solution

    07-18-2007, 10:02 PM
    • Loading...
    • CalZ
    • Joined on 07-19-2007, 12:59 AM
    • Posts 10

    Yup I'm where you're at as well. It's a little silly that just getting buttons to work in an accordion can be so complex haha.

    I have gotten buttons to work, but only when I manually create the accordionpanes and do the oninit() trick.  That's not we want of course, there must be a way to wire up a databound accordion to get control events to fire.  I don't know how to tap into an accordionpane's oninit function when they are created through databinding though, does anyone have a solution?

     

    - Calvin 

    Filed under: ,
  • Re: The solution

    07-19-2007, 4:39 PM

     So far the best I can do is get the double click effect on a databound accordion. Add a empty panel and set its visibility to false, and you get the problems noted here http://forums.asp.net/t/1017782.aspx. But the fixes they talked about don't seem to work for the databound panels.

    If I get any farther with a work around I will let you all know. 

     

  • Re: The solution

    07-23-2007, 1:17 PM

     Ok, so what I came up with was to actually change the source code. Its not a lot to change, but its not 100% perfect.

     Also, I can't take credit for this, because I gathered the combined changes required from various sources, but here it is:

     The Accordion Class needs to be changed from a WebControl to a CompositeControl.

     source: here

    And both the Accordion Class and the Accordion Panel Class need to use the INamingContainer.

     source: here

    Here is an example of the change:

    was: public class Accordion : WebControl

    is now: public class Accordion : CompositeControl, INamingContainer

    Hope this helps some people.

  • Re: The solution

    07-25-2007, 8:14 AM
    • Loading...
    • CalZ
    • Joined on 07-19-2007, 12:59 AM
    • Posts 10

    I made the change but now clicking buttons makes the entire accordion disappear.  I'm not positive it's due to changing the base to compositecontrol though, because I was fiddling with a ton of other stuff before I caught your post.  It's way too late in my project to try to keep messing around with the control however, so it's back to old school repeaters for me. 

  • Re: The solution

    07-25-2007, 11:41 AM
    CalZ:

    I made the change but now clicking buttons makes the entire accordion disappear.  I'm not positive it's due to changing the base to compositecontrol though, because I was fiddling with a ton of other stuff before I caught your post.  It's way too late in my project to try to keep messing around with the control however, so it's back to old school repeaters for me. 

      I had that issue as well... where are you doing the databind?

  • Re: The solution

    07-25-2007, 1:25 PM
    • Loading...
    • CalZ
    • Joined on 07-19-2007, 12:59 AM
    • Posts 10

    I'm binding it in the markup:

    <cc1:Accordion ID="AccordionResults" runat="server" DataSourceID="SqlDataSourceResults" SelectedIndex="-1" RequireOpenedPane="false" FadeTransitions="true" OnItemCreated="InitPanes" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent"  Width="800px">
            

     And onItemCreated calls:

        Protected Sub InitPanes(ByVal sender As Object, ByVal e As AjaxControlToolkit.AccordionItemEventArgs)

            Dim myAccordionPane As AjaxControlToolkit.AccordionContentPanel = CType(e.AccordionItem, AjaxControlToolkit.AccordionContentPanel)
            Dim workAroundLabel As New Label
            workAroundLabel.Visible = False
            myAccordionPane.Controls.Add(workAroundLabel)

        End Sub

     

  • Re: The solution

    07-25-2007, 2:22 PM

    Well, before I make any suggestions, realize I am not an expert at this by any measure. But when I experienced the same symptoms, it was because I was Adding controls before I was binding the data (so adding controls to an accordion with no panes), or at least thats what I thought.

    Looking at you're code, my only suggestion is that you remove the work around label and give it one last try.

    Sorry I cant be of more help.