This is a migrated thread and some comments may be shown as answers.

Missing paging support for ObjectDataSource

1 Answer 74 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Zsolt
Top achievements
Rank 1
Zsolt asked on 24 Jun 2010, 02:58 PM
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:
<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?


1 Answer, 1 is accepted

Sort by
0
Accepted
Kalina
Telerik team
answered on 29 Jun 2010, 01:39 PM
Hi Zsolt Molnar,

As I can see from the code snippets provided – you use a RadComboBox with Automatic-Load-On-Demand enabled.
The Automatic-Load-On-Demand feature supports its own paging functionality which works with all types of enumerable data sources and performs paging automatically.  
That is why the RadComboBox control can be populated via ObjectDataSource but does not use the paging logic that this data source provides.
However your approach to implement a different paging manually is correct.

Feel free to contact us if you have additional questions.

All the best,
Kalina
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
Zsolt
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Share this question
or