One workaround is to remove nodes that are not visible, e.g., in the Page_Load event: RadNavigation1.Nodes.RemoveAll(x => !x.Visible); Another workaround is to remove the HTML of hidden nodes. Note that this will not affect the nodes collections and they will still be present. Invoking operations or methods on such removed nodes can cause errors. <telerik:RadNavigation runat="server" ID="RadNavigation1" OnClientLoad="OnClientLoad"> <Nodes> <telerik:NavigationNode Text="first"></telerik:NavigationNode> <telerik:NavigationNode Text="second" Visible="false"></telerik:NavigationNode> <telerik:NavigationNode Text="third"></telerik:NavigationNode> </Nodes> </telerik:RadNavigation> <script> function OnClientLoad(sender, args) { var nodes = sender.get_allNodes(); var indicesToRemove = []; for (var i = 0; i < nodes.length; i++) { if (nodes[i].get_element().style.display == "none") { $telerik.$(nodes[i].get_element()).remove(); } } } </script>
1. Click the ComboBox
2. Select an item in its dropdown
3. Expected: no exception on selection, actual: A "Selection out of range" exception is thrown.
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
public partial class ComboBoxNavigation : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
private DataTable CreateTestTable()
{
DataTable table = new DataTable();
table.Columns.Add("Text");
table.Columns.Add("Value");
table.Columns.Add("test");
table.Rows.Add("Item1", "1", "aaa");
table.Rows.Add("Item1", "1", "aaa");
table.Rows.Add("Item1", "1", "aaa");
return table;
}
protected void rcbStaff_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
RadComboBox rcbUser = sender as RadComboBox;
rcbUser.DataSource = CreateTestTable();
rcbUser.DataTextField = "Text";
rcbUser.DataValueField = "Value";
rcbUser.DataBind();
}
protected void rcbStaff_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
}
}
<telerik:RadNavigation ID="RadNavigation1" runat="server">
<Nodes>
<telerik:NavigationNode Text="Home" />
<telerik:NavigationNode Text="Candidate" />
<telerik:NavigationNode Text="Preliminary Candidate" />
<telerik:NavigationNode Text="StaffSearch" CssClass="staffSearchWrapper rootTemplate">
<NodeTemplate>
<telerik:RadComboBox ID="rcbStaff"
AutoPostBack="true"
runat="server"
EnableLoadOnDemand="True"
OnItemsRequested="rcbStaff_ItemsRequested"
OnSelectedIndexChanged="rcbStaff_SelectedIndexChanged"
>
</telerik:RadComboBox>
</NodeTemplate>
</telerik:NavigationNode>
</Nodes>
</telerik:RadNavigation>