Load On Demand DropDownList (& DropDownListElement)

4 posts, 0 answers
  1. Raoul
    Raoul avatar
    33 posts
    Member since:
    Apr 2012

    Posted 12 Feb 2013 Link to this post


    RadControls version 2012.2.726.40
    .NET version 3.5
    Visual Studio version 2010 & 2012
    programming language VB.Net & C#

    This project demonstrates "load on demand" functionality for a dropdownlist and the dropdownlistelement in a grid. Though using a dropdownlist to select from a large list of data is arguably not the best solution, the autocomplete mode of the dropdownlist is a very user friendly way to let your user choose from a large list of possible choices. However, binding large amount of data to controls does not improve the performance. Load on demand can help but is only available with the controls for ASP.NET and currently not supported by the WinForms RadDropDownList.

    The solutions contains 2 identical projects, one in VB.Net and one in C#. It is a single RadForm containing a RadDropDownList control and a RadGridView. All controls keep the designer defaults when placed on the form. Sample data is provided by the ExampleData class, which is able to generate a list of ExampleData objects to populate the dropdownlist. RadLabels are used to show the real time values of the RadDropDownList selected value.
    Only when the user selects an item from the dropdownlist, or when the (text-)input exactly matches the displaymember of a listed item, the selected index of the dropdownlist is set.

    When the application loads, RadDropDownList1 is initialized to act as a load on demand control. This is done in code behind to show which properties and events are used, but could also be done using the visual studio designer. Same applies to the settings of RadGridView1, more specifically the  GridViewComboBoxColumn.
    The RadDropDownList starts loading content when the user enters at least two characters (see KeyUp event). The gridviewcombobox refreshes after each keypress. Load on demand functionality for the gridviewcombobox is provided by changing the default editor to a "load on demand editor" using the RadGridView1_EditorRequired event.

    Though in the example project a object list serves as the dropdownlist datasource, it should work with other data sources as well.
    I hope you find this project helpful. I'm open to suggestions and improvements from the Telerik community.

    To test it, simply add "ab", "de" or any other string from the list in the ExampleData class and the control will be populated accordingly.

  2. Stefan
    Stefan avatar
    2891 posts

    Posted 15 Feb 2013 Link to this post

    Hi Raoul,

    Thank you very much for sharing your code with the community. I can say that this is an example of a CodeLibrary article - nice feature implemented, covered with detailed documentation and in both C# and VB.NET. Additionally, perfect explanation is provided as well.

    I am sure that this will be useful to many users.

    I have added 3000
    Telerik Points to your account for your time and efforts.

    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  3. KennethMoss
    KennethMoss avatar
    4 posts
    Member since:
    Apr 2007

    Posted 11 Jun 2015 in reply to Stefan Link to this post

    This is a great example.   

    1) How do you get the project to work when the user attempts to modify an existing dropdown field in the Grid?  I have attached a video of the issue when I attempt to modify the existing value. 

    2) Is it possible to filter where it beginswith (just as it does in the example) but also to only return the top nth (i.e. 100) values?


  4. Dimitar
    Dimitar avatar
    1337 posts

    Posted 12 Jun 2015 Link to this post

    Hello Kenneth,

    Thank you for writing.

    1. In this case the cell value is set to a string (like "abc4560") and the second time when it is not modified it is retrieved from the grid directly not from the editor and in this case it cannot be parsed to a Guid. This can be solved by overriding the IsModified property in the custom editor class:
    Public Overrides ReadOnly Property IsModified As Boolean
            Return True
        End Get
    End Property

    2. Yes it is, you can take any number of results you want. This can be achieved when the data source is assigned:
    ddl.DataSource = _dropDownDataSource.Where(Function(c) c.ExampleDisplayMember.StartsWith(txt)).Take(2)
    In addition I want to mention that we have another example for this: Server side auto complete for RadDropDownList.

    I hope this helps.

    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
Back to Top