Hello,
I am using JavaScript to remove some SearchContext items from the dropdown list. After executing the code below, the items remain in the Search Context dropdown list, but their selection no longer works correctly. I have tried both itemsCollection.removeAt(i); and itemsCollection.remove(item); and both behave in the same way. If this is a bug, is there a way to define these items in server side code (C#)? That way I can decide which items to add. Thinking about it, I guess I could try adding the items on the client side, rather than declaratively.
JS Code to remove the desired items: I have stepped through vis the debugger to ensure the code is executed as expected.
var searchBox = $find("<%=SearchRadSearchBox.ClientID%>");if (searchBox) { searchContext = searchBox.get_searchContext(); if (searchContext) { itemsCollection = searchContext.get_items(); for (var i = itemsCollection.get_count() - 1; i >= 0; i--) { item = itemsCollection.getItem(i); if (item) { if (item.get_text() == 'Joint Barcode' || item.get_text() == 'Weld Barcode') { // remove the item itemsCollection.removeAt(i); } } } }}
Definition of the SearchBox:
<telerik:RadSearchBox RenderMode="Lightweight" ID="SearchRadSearchBox" runat="server" Width="500" OnSearch="SearchRadSearchBox_Search" EnableAutoComplete="False"> <Localization DefaultItemText="General" LoadingItemsMessage="Some Loading" /> <SearchContext> <Items> <telerik:SearchContextItem Text="Document Type" Key="1" /> <telerik:SearchContextItem Text="Heat Number" Key="2" /> <telerik:SearchContextItem Text="Spread" Key="3" /> <telerik:SearchContextItem Text="Joint Barcode" Key="4" /> <telerik:SearchContextItem Text="Weld Barcode" Key="5" /> </Items> </SearchContext></telerik:RadSearchBox>