RadControls for ASP.NET AJAX
RadListBox Load On Demand
RadListBox Load On Demand Overview
Set the EnableLoadOnDemand property to true
Set Height to RadListBox. If the
property is set to
, but there is no Height set, RadListBox will not utilize on demand loading. (The Height property is needed in order scrollbars to appear).
Assign a data source to RadListBox, this can be done both from code-behind or declaratively
The DataSource property needs to be set each and every time the server is hit. This is necessary, because when Load On Demand is used, RadListBox doesn’t keep track of its items. They are not added to the Items collection and thus not allowing manipulating them on the server. RadListBox Load on Demand is entirely client feature.
Here is short example of how RadListBox should be bound in a Load on Demand scenarios:
<telerik:RadListBox runat="server" ID="RadListBox1" Height="200px"
Another example, demonstrating binding to a declarative datasource. In this case there is no code behind code needed. One only need
to set the DataSourceID and DataTextField property of RadListBox:
<telerik:RadListBox runat="server" ID="RadListBox1" Height="200px" DataKeyField="ProductID"
EnableLoadOnDemand="true" Width="300px" CheckBoxes="true" DataSourceID="SqlDataSource1">
<asp:SqlDataSource runat="server" ID="SqlDataSource1"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [ProductID], [ProductName] FROM [Alphabetical list of products]">
Since RadListBox utilizes ASP.NET Callbacks for Load on Demand it is necessary,that we use the not Page is Callback condition for binding it. This means that RadListBox should only be bound on initial load after which the callback mechanism will take care of data binding.
On client-side, Load on demand is triggered in the following occasions:
Scroll using the mouse wheel –this fires LOD as items are being scrolled.
Scroll via moving the scrollbar- this fires LOD on mouse up, i.e. the items are going to be requested only after the user has finished scrolling.
RadListBox will load only the items that fit in the visible area.
Accessing item using the API :
You need to use the GetItemAsync method instead of GetItem
If the sought item is loaded, RadListBox will immediately pass it to the callback. If it is not, a request will be made to the server and upon retrieval the item will be passed as an argument to the provided callback.
You could use RadLoadingPanel to display loading template between the AJAX requests. Just place a loading panel on the page and set the LoadingPanelID property of the ListBox to the RadLoadingPanel ones.
Load On Demand limitations:
Any server-side operations (Transfer,Reoderder, SelectedIndexChanged) are not supported on the server.
RadListBox LOD is entirely client feature.
Client-side Reordering is not supported in LOD scenarios
Whereas transferring the selected items is possible, transfer all items is not supported since in LOD scenarios this would most likely cause
the browser to halt.