Hello,
I am trying to implement a RadComboBox with a datasource that can have up to 2,000 items. Therefore it is import that all the items do not get loaded at once. However I also want a RadComboBox with checkboxes, and I want to be able to select multiple values. The issue I am running into is when I have EnableLoadOnDemand="true" the checkboxes that were checked when searching for one word do not persist.
As an example: If I search for "Apple" check that off and then search for "Zinc" check that off and search for "Apple" again, the checkbox for "Apple" will not appear checked off. This happens even if open the drop down and check of the first 5 items then search for something that's not being displayed in the dropdown, or something that is being displayed, it doesn't change the behavior, check that off and then go back to the original 5 items and they appear unchecked.
The issue doesn't appear to happen if EnableLoadOnDemand="false" however then the ComboBox control will try and load all 2,000 items and the page will start slowing down.
I want to know if there is a way to get this behavior either with EnableLoadOnDemand="true" or if its possible to limit how many items are displayed when EnableLoadOnDemand = "false". Also note that the OnItemsRequested event does not get raised when EnableLoadOnDemand is set to False.
Markup:
<
telerik:RadComboBox
ID
=
"RadComboBox2"
runat
=
"server"
Visible
=
"true"
MaxHeight
=
"330"
Width
=
" 200px"
Label
=
"Look up values:"
filter
=
"Contains"
AutoPostBack
=
"false"
EnableLoadOnDemand
=
"true"
EmptyMessage
=
"Search Code..."
OnItemsRequested
=
"RadComboBoxLargeLookup_ItemsRequested"
ShowMoreResultsBox
=
"true"
ItemsPerRequest
=
"50"
EnableViewState
=
"true"
>
<
ItemTemplate
>
<
table
>
<
tr
>
<
td
><
input
type
=
"checkbox"
/></
td
>
<
td
><
asp:Label
runat
=
"server"
id
=
"asdfasdf"
Text='<%# DataBinder.Eval(Container, "Text")%>' /></
td
>
</
tr
>
</
table
>
</
ItemTemplate
>
</
telerik:RadComboBox
>
Code Behind:
protected
void
RadComboBoxLargeLookup_ItemsRequested(
object
sender, RadComboBoxItemsRequestedEventArgs e)
{
try
{
DataTable data = (DataTable)(
this
.ViewState[
"LookupValues"
]);
int
itemOffset = e.NumberOfItems;
int
endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count);
e.EndOfItems = endOffset == data.Rows.Count;
for
(
int
i = itemOffset; i < endOffset; i++)
{
RadComboBoxItem item =
new
RadComboBoxItem();
string
name = data.Rows[i][
"SortField"
].ToString();
string
code = data.Rows[i][
"Code"
].ToString();
item.Text = name;
item.Value = code;
RadComboBox radComboBox = sender
as
RadComboBox;
radComboBox.Items.Add(item);
item.DataBind();
}
}
catch
(Exception ex)
{
}
}
Final goal is to allow the user to select multiple options and retain the ones that were selected that are not being displayed in the dropdown.
I also set EnabledViewState="true" per a recommendation on another support item, but that did not do anything.
Any advice is appreciated.
-Klaus