RadComboBox provides its own Load On Demand mechanism - the RadComboBox loads its
Items when you open the DropDown for the first time and when you type any text in
the input. There are two types of Load On Demand mechanisms - Server-Side and Web
Service.
You can you use either automatic or manual Server-Side Load On Demand.
In order to use the manual Server-Side approach set the EnableLoadOnDemand
property to true and handle the ItemsRequested
event, which fires each time Items are requested by the RadComboBox. The server-side
event handler should return all relative matches for the currently typed text.
In order to load Items on portions (let say by 10 or 15, etc.) instead of loading
all Items matching the given text you can set the ShowMoreResultsBox
property to true. This will enable the footer which shows which
Items are currently loaded and how many remain. Then you must implement the ItemsRequested
event handler in a way it returns only the next number of Items. Using this approach
you can achieve better performance in cases many Items are to be loaded in the RadComboBox.
Additionally you can set the EnableVirtualScrolling property to
true and RadComboBox will load Items on portions even when you
scroll the DropDown.
Setting up the automatic Load On Demand is straightforward:
- Set a data source to the RadComboBox. Use either DataSourceID or
the DataSource property to do this
and set the DataTextField and DataValueField properties
to the respective fields in the data source.
(Note that when using DataSource you must set the property on each postback, most
conveniently in Page_Init.)
- Set EnableAutomaticLoadOnDemand to true.
- (Optional) Set ShowMoreResultsBox/EnableVirtualScrolling to
true to enable the respective features.
- (Optional) Set ItemsPerRequest to the number of Items you would
like to load per request. The default (-1) loads all Items at once.
Note: When you use the DataSourceID or DataSource properties to bind RadComboBox
during automatic Load On Demand the
ItemDataBound event fires normally, which means that you can use it to change
the Item's Text and Value properties as well as modify its Attributes collection
based on the DataItem, etc.
In order to use a Web Service you must first mark it with the ScriptService
attribute and expose a public method (marked with the WebMethod
attribute) which would load Items similarly as in the Server-Side approach. The
other difference in this approach is that data should be returned in objects of
a custom serializable type.
Finally, you should keep into account that the AllowCustomText
property is enabled (set to true) by default when the Load On Demand
mechanism is enabled and the value set to the property is ignored.