Event not firing in RadPanelBar

7 posts, 0 answers
  1. Scott
    Scott avatar
    22 posts
    Member since:
    Aug 2012

    Posted 03 Sep 2015 Link to this post

    I have a RadGrid with that works correctly outside of the RadPanelBar.  When I put it inside of a RadPanelBar the OnCheckedChanged="ToggleRowSelection" does not fire.  Does "protected void ToggleRowSelection(object sender, EventArgs e)" need to be defined differently?  It looks like the auto post back works because the check mark disappears.  If I remove ToggleRowSelection in the c# section I get a compile error indicating that there is no definition for ToggleRowSelection so I think it is all correct. 

     Thanks,

     Scott

    <telerik:RadPanelBar ID="RadPanelBar1" Runat="server" Width="774px">
           <Items>
               <telerik:RadPanelItem runat="server" Text="Web Servers">
                       <ContentTemplate>
                           <telerik:RadGrid ID="WebServerRadGrid" runat="server" AllowPaging="True" PageSize="5" Skin="Silk" AllowMultiRowSelection="true">
                              <MasterTableView>
                                  <Columns>
                                    <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn">
                                     <ItemTemplate>
                                        <asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="ToggleRowSelection" AutoPostBack="True" />
                                     </ItemTemplate>
                                  </telerik:GridTemplateColumn>
                                </Columns>
                              </MasterTableView>
                           </telerik:RadGrid>
                       </ContentTemplate>
               </telerik:RadPanelItem>
            </Items>
       </telerik:RadPanelBar>

     

     

    protected void ToggleRowSelection(object sender, EventArgs e)
      {
          ((sender as CheckBox).NamingContainer as GridItem).Selected = (sender as CheckBox).Checked;
          bool checkHeader = true;
          foreach (GridDataItem dataItem in WebServerRadGrid.MasterTableView.Items)
          {
              if (!(dataItem.FindControl("CheckBox1") as CheckBox).Checked)
              {
                  checkHeader = false;
                  break;
              }
          }
          GridHeaderItem headerItem = WebServerRadGrid.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;
          (headerItem.FindControl("headerChkbox") as CheckBox).Checked = checkHeader;
      }

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 08 Sep 2015 Link to this post

    Hello Scott,

    I tested your scenario and at my side the event fires correctly regardless of the Grid being placed in the PanelBar's template or not. You can find a sample website attached to this reply.

    Regards,
    Ivan Danchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Scott
    Scott avatar
    22 posts
    Member since:
    Aug 2012

    Posted 08 Sep 2015 in reply to Ivan Danchev Link to this post

    Your example works.  My problem seems to be when I use a DataTable to specify the data that appears in the grid.  When I switch to DataSourceID="SqlDataSource" mine works.  Am I missing something that needs to be done?  

     

    DataTable table = new DataTable();
    table.Columns.Add("Server", typeof(string));
    table.Columns.Add("Comment", typeof(string));
    ...
     
    RadGrid1.DataSource = table;
    RadGrid1.DataBind();

     

  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 11 Sep 2015 Link to this post

    Hello Scott,

    There is no difference at my side when binding the Grid to a DataTable (see the attached sample page) and the CheckBox' OnCheckedChanged event fires as expected.

    I would suggest checking for js errors in the browser's developer tools as they could be a potential cause for the event not firing.

    Regards,
    Ivan Danchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Scott
    Scott avatar
    22 posts
    Member since:
    Aug 2012

    Posted 23 Sep 2015 in reply to Ivan Danchev Link to this post

    I still am having problems.  Your examples work, but they make enough changes so that when I try to make it do what I want it breaks. I have pages that fix one thing, but break another.

    Is there any other code (this is not a web application) besides the .aspx code listed here that I need to look at to see why things are not firing or being seen?    

     For example on this page the OnCheckedChanged="ToggleRowSelection" is not firing, but I can see all the radgrids (I added others).

    <telerik:RadPanelBar ID="RadPanelBar1" Runat="server">
            <Items>
                <telerik:RadPanelItem runat="server" Text="Root RadPanelItem1">
                    <ContentTemplate>
                        <asp:Button ID="Button1" runat="server" OnClick="Action_Button_Click" Text="Button" />
                        <telerik:RadGrid ID="WebServerRadGrid" runat="server" AllowMultiRowSelection="true">
                                 <MasterTableView>
                                   <Columns>
                                     <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn">
                                      <ItemTemplate>
                                         <asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="ToggleRowSelection" AutoPostBack="True" />
                                      </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                 </Columns>
                               </MasterTableView>
                        </telerik:RadGrid>
                    </ContentTemplate>
                </telerik:RadPanelItem>
                <telerik:RadPanelItem runat="server" Text="Root RadPanelItem2">
                    <ContentTemplate>
                        <asp:Button ID="Button2" runat="server" Text="Button" />
                        <telerik:RadGrid ID="RadGrid2" runat="server">
                        </telerik:RadGrid>
                    </ContentTemplate>
                </telerik:RadPanelItem>
            </Items>
        </telerik:RadPanelBar>

     

    And in this example the OnCheckedChanged works, but The code behind can't see two of the RadGrids.  

    GridDataItemCollection Items = null;
    Items = WebServerRadGrid.MasterTableView.Items;   //OK
    Items = NetSageRadGrid.MasterTableView.Items;       // The name 'NetSageRagGrid' does not exist in the current content
    Items = FeederRadGrid.MasterTableView.Items;          // The name 'FeederRagGrid' does not exist in the current content

    <telerik:RadPanelBar ID="RadPanelBar1" Runat="server" Width="774px">
           <Items>
               <telerik:RadPanelItem runat="server" Text="Web Servers">
                       <ContentTemplate>
                          <asp:Button ID="QueryButton" CommandArgument="webservers" CommandName="Query" runat="server" OnClick="Action_Button_Click" Text="Query Servers" />
                          <asp:Button ID="Button2" runat="server" Text="Button" />
                           <telerik:RadGrid ID="WebServerRadGrid" runat="server" AllowMultiRowSelection="true">
                              <MasterTableView>
                                  <Columns>
                                    <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn">
                                     <ItemTemplate>
                                        <asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="ToggleRowSelection" AutoPostBack="True" />
                                     </ItemTemplate>
                                  </telerik:GridTemplateColumn>
                                </Columns>
                              </MasterTableView>
                           </telerik:RadGrid>
                       </ContentTemplate>
               </telerik:RadPanelItem>
               <telerik:RadPanelItem runat="server" Text="NetSage Servers">
                    <ContentTemplate>
                          <asp:Button ID="Button1" CommandArgument="netsageservers" CommandName="Query" runat="server" OnClick="Action_Button_Click" Text="Query Servers" />
                          <asp:Button ID="Button3" runat="server" Text="Button" />
                           <telerik:RadGrid ID="NetSageRadGrid" runat="server"  AllowMultiRowSelection="true">
                              <MasterTableView>
                                  <Columns>
                                    <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn">
                                     <ItemTemplate>
                                        <asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="ToggleRowSelection" AutoPostBack="True" />
                                     </ItemTemplate>
                                  </telerik:GridTemplateColumn>
                                </Columns>
                              </MasterTableView>
                           </telerik:RadGrid>
                       </ContentTemplate>
               </telerik:RadPanelItem>
               <telerik:RadPanelItem runat="server" Text="Feeder Servers">
                    <ContentTemplate>
                          <asp:Button ID="Button5" CommandArgument="feederservers" CommandName="Query" runat="server" OnClick="QueryButton_Click" Text="Query Servers" />
                          <asp:Button ID="Button6" runat="server" Text="Button" />
                           <telerik:RadGrid ID="FeederRadGrid" runat="server"  AllowMultiRowSelection="true">
                              <MasterTableView>
                                  <Columns>
                                    <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn">
                                     <ItemTemplate>
                                        <asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="ToggleRowSelection" AutoPostBack="True" />
                                     </ItemTemplate>
                                  </telerik:GridTemplateColumn>
                                </Columns>
                              </MasterTableView>
                           </telerik:RadGrid>
                       </ContentTemplate>
               </telerik:RadPanelItem>
            </Items>
       </telerik:RadPanelBar>

    The code behind can see 

        GridDataItemCollection Items = null;

    Items = WebServerRadGrid.MasterTableView.Items;   //OK
    Items = NetSageRadGrid.MasterTableView.Items;       // The name 'NetSageRagGrid' does not exist in the current content
    Items = FeederRadGrid.MasterTableView.Items;          // The name 'FeederRagGrid' does not exist in the current content

  7. Alvin
    Alvin avatar
    1 posts
    Member since:
    Jun 2012

    Posted 23 Sep 2015 in reply to Scott Link to this post

    I had forgot to check for postback.  Once this was added it fixed one problem.  That is good enough at the moment.    

     if (!IsPostBack)

  8. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 24 Sep 2015 Link to this post

    Hello,

    Thank you for getting back to us and sharing what was causing the issue.

    Regards,
    Ivan Danchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017