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

Event not firing in RadPanelBar

6 Answers 23 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 03 Sep 2015, 09:43 PM

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;
  }

6 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 08 Sep 2015, 08:46 AM
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
0
Scott
Top achievements
Rank 1
answered on 08 Sep 2015, 07:50 PM

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();

 

0
Ivan Danchev
Telerik team
answered on 11 Sep 2015, 10:52 AM
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
0
Scott
Top achievements
Rank 1
answered on 23 Sep 2015, 08:24 PM

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

0
Alvin
Top achievements
Rank 1
answered on 23 Sep 2015, 10:02 PM

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

 if (!IsPostBack)

0
Ivan Danchev
Telerik team
answered on 24 Sep 2015, 11:45 AM
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
Tags
PanelBar
Asked by
Scott
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Scott
Top achievements
Rank 1
Alvin
Top achievements
Rank 1
Share this question
or