This example demonstrates how to achieve the best performance with RadComboBox when dealing with large ammounts of data (items).
The important steps are:
-
Use Web Service load on demand.
Web Service load on demand does not request the page and avoids the execution of the page life cycle.
Less data is transferred between the client and the server.
-
The using of EnabelItemCaching
This property will save a time and use the result from the previous request with the same parameters.
-
The implementation of the Web Service methods uses two optimization techniques to decrease the size of the generated JSON output:
-
The return type of the web method is IEnumerable. This prevents the serialization of the type name in the JSON output:
[WebMethod]
public IEnumerable GetItems(RadComboBoxContext context)
{
int numberOfItems = 1000;
List<ComboBoxItemData> items = new List<ComboBoxItemData>();
for (int i = 0; i < numberOfItems; i++)
{
ComboBoxItemData itemData = new ComboBoxItemData();
itemData.Text = "Item " + i;
items.Add(itemData);
}
return items;
}
-
The web method returns only the data required by the application. In this case only the item's Text property is serialized by using a custom class - ComboBoxItemData.
You should prefer this approach over using the RadComboBoxItemData or RadComboBox classes to preserve output size:
class ComboBoxItemData
{
private string text;
public string Text
{
get { return text; }
set { text = value; }
}
}
The OnClientItemsRequesting and OnClientItemsRequested events are used only to measure the time requred to perform the load on demand operation.
Consuming them is not required for the proper operation of RadComboBox in this scenario.