There is an automatic feature on RadGrid (and on the default ASP.NET
GridView) control for paging the rows in grid. If the datasource is an
ObjectDataSource and we set the Select, Insert, Update, Delete,
SelectCount methods, and set the EnablePaging="true", and the
StartRowIndexParameterName, MaximumRowsParameterName properties also
filled with the name of parameters of the ObjectDataSource overloaded
method for paging, then the RadComboBox does not set value for the
startRow and the pageSize parameter. As a side-effect the RadComboBox
does not call the SelectCount method too.
Here is an example:
The ObjectDataSource declaration:
The select methods of the TableAdapter class:
The select count method of the Adapter class:
The RadComboBox that is using the declared ObjectDaraSource below:
My workaround: I've created some Session variable to retrieve the required variables (startRow, pageSize) at ObjectDataSource.Selecting event and set when the ItemRequested.
The questions:
Why RadComboBox does not support a similiar paging behavior as RadGrid supports?
Will the new beta support this automatically as RadGrid supports it?
Maybe I can't understand well the possibilities with RadComboBox and everything works fine if the datasource is ObjectDataSource. I don't want to preclude my mistake. :) So if there is a support for ObjectDataSource paging then how should I use RadComboBox with ObjectDataSource?
Here is an example:
The ObjectDataSource declaration:
<asp:ObjectDataSource ID="dsEmplTable" runat="server" DataObjectTypeName="TableObjects.EmplTable" |
TypeName="TableObjects.EmplTableAdapter" DeleteMethod="DeleteEmplTable" |
InsertMethod="InsertEmplTable" SelectMethod="SelectEmplTable" UpdateMethod="UpdateEmplTable" |
OldValuesParameterFormatString="original_{0}" EnableCaching="true" CacheDuration="10" |
SortParameterName="sortExpression" SelectCountMethod="SelectCount" |
EnablePaging="true" StartRowIndexParameterName="startRow" MaximumRowsParameterName="pageSize" |
> |
The select methods of the TableAdapter class:
[DataObjectMethod(DataObjectMethodType.Select, true)] |
public EmplTableList SelectEmplTable(string sortExpression, int startRow, int pageSize) |
{ |
//If we use RadComboBox then the values of the startRow and the pageSize variables are 0 |
//If we use RadGrid then these parameters filled properly by default |
//Here we want select only a range of employees from a tons of employee |
DataAccessLayer.GetEmployees(emplTableCollection, startRow, pageSize); |
SelectCount = emplTableCollection.Count; |
_empltableData = empltableCollection; |
return _empltableData; |
} |
- SelectCount is a property on Adapter and its value is strored in Session variable for performance issue
The select count method of the Adapter class:
public int SelectCountEmplTable() |
{ |
return SelectCount; |
} |
The RadComboBox that is using the declared ObjectDaraSource below:
<telerik:RadComboBox runat="server" ID="RadComboBox2" DataTextField="EmplId" |
DataValueField="EmplId" HighlightTemplatedItems="true" Height="190px" Width="220px" |
DropDownWidth="420px" DataSourceID="dsEmplTable" EnableVirtualScrolling="true" |
EnableAutomaticLoadOnDemand="True" ItemsPerRequest="10" ShowMoreResultsBox="true" |
OnItemsRequested="RadComboBox2_ItemRequested" |
OnItemDataBound="RadComboBox2_ItemDataBound" |
OnSelectedIndexChanged="RadComboBox2_SelectedIndexChanged" |
OnDataBinding="RadComboBox2_DataBinding" |
> |
<HeaderTemplate> |
<ul> |
<li class="col1">Employee Id</li> |
</ul> |
</HeaderTemplate> |
<ItemTemplate> |
<ul> |
<li class="col1"><%# DataBinder.Eval(Container.DataItem, "EmplId") %></li> |
</ul> |
</ItemTemplate> |
</telerik:RadComboBox> |
My workaround: I've created some Session variable to retrieve the required variables (startRow, pageSize) at ObjectDataSource.Selecting event and set when the ItemRequested.
protected void Page_Load(object sender, EventArgs e) |
{ |
this.dsEmplTable.Selecting += new ObjectDataSourceSelectingEventHandler(dsEmplTable_Selecting); |
if (Session["RADCOMBOBOX2_STARTROW"] == null) |
{ |
Session.Add("RADCOMBOBOX2_STARTROW", 1); |
} |
} |
void dsEmplTable_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) |
{ |
e.Arguments.StartRowIndex = (int)Session["RADCOMBOBOX2_STARTROW"]; |
e.Arguments.MaximumRows = (int)Session["RADCOMBOBOX2_MAXIMUMROWS"]; |
} |
The questions:
Why RadComboBox does not support a similiar paging behavior as RadGrid supports?
Will the new beta support this automatically as RadGrid supports it?
Maybe I can't understand well the possibilities with RadComboBox and everything works fine if the datasource is ObjectDataSource. I don't want to preclude my mistake. :) So if there is a support for ObjectDataSource paging then how should I use RadComboBox with ObjectDataSource?