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

ComboBox LoadOnDemand with Checkbox Mutliple Selection not working

3 Answers 353 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Klaus
Top achievements
Rank 1
Klaus asked on 10 Jul 2013, 10:55 PM

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

3 Answers, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 15 Jul 2013, 07:55 AM
Hi Klaus,

Thank you for contacting Telerik support.

The reason why you are experiencing issues with the Check Box support in LoadOnDemand scenarios is cause by the fact that these two features are not intended to work together and therefore their simultaneous usage is not supported as outlined the following help article here. In order to have loading on demand and multiple selection my suggestion is to try the RadAutoCompleteBox control which support these feature of the box and it's designed for such particular scenarios.

Hope this information would be helpful.

Regards,
Dimitar Terziev
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
arun
Top achievements
Rank 1
answered on 27 Jun 2014, 03:57 PM
Is there any possibility that this support is in the works or will be added in the future.

Thanks
0
Nencho
Telerik team
answered on 02 Jul 2014, 08:02 AM
Hello Arun,

This simultaneous usage of both features will not be implemented, since RadComboBox's items loaded on demand are not accessible on the server, which on the other hand is needed for the CheckBox feature. However, you could use ItemTemplate, along with LoadOnDemand enabled and place the checkboxes in the template.

I would suggest you to refer to the following forum thread, where this functionality is discussed and a sample projects are provided:

http://www.telerik.com/forums/radcombo-multi-select-and-load-on-demand

Regards,
Nencho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ComboBox
Asked by
Klaus
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
arun
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or