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

NeedDataSource Server Bind to a remote Wcf Service

1 Answer 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mauro
Top achievements
Rank 1
Mauro asked on 03 Feb 2015, 04:48 PM
Hi,
     i would like to know if it is possible to know if it is possible to extract the pager information during the NeedDataSource event.

I supposed it can be done with a custom pager, but i would like to reuse basic pager.
I need this because i have not a local db, but have to call a remote wcf service with a simple call (no odata or similar).

If cannot, do you suggest ObjectDataSource or Custom Pager?

Thx in advance
Mauro Dalla Zuanna

<telerik:RadGrid ID="RadGridMain" runat="server" AllowSorting="True" AllowPaging="True" AllowFilteringByColumn="True" PageSize="12" 
OnNeedDataSource="RadGridTransazioni_NeedDataSource">

....

</telerik:RadGrid>

#Code behind
protected void RadGridMain_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) {
  WcfClient client = new WcfClient();
  List<DataType> returnedData = client.ReturnData( <... sort, page number, number of records ...>);
  this.RadGridMain.DataSource = returnedData;
}

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 06 Feb 2015, 11:58 AM
Hi Mauro,

If by the pager information you refer to the current page index and page size indeed you can extract this information inside the NeedDataSource event handler. An example on how to achieve this is provided below.

C#:
protected void RadGridMain_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        ....
        int currentpage = RadGridMain.CurrentPageIndex;
        int pageSize = RadGridMain.PageSize;
    }


Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Mauro
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or