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

[Solved] Paging with External Web services

2 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 26 Feb 2012, 03:13 AM
Is it possible to support paging with External Webservices where you are pulling data in the OnDataBinding event handler, like it is shown for the facebook and twitter demo's?

2 Answers, 1 is accepted

Sort by
0
Dadv
Top achievements
Rank 1
answered on 27 Feb 2012, 11:50 AM
Hi,

GridState have Page and Size property, what do you want exactly ?
0
Atanas Korchev
Telerik team
answered on 01 Mar 2012, 08:49 AM
Hi,

 This should be possible after enabling client operation mode and setting the total field before calling the dataBind method:

<%= Html.Telerik().Grid<TwitterItem>()
     .Name("Grid")
     .Columns(columns =>
     {
         columns.Bound(o => o.text).Title("Post");
     })
     .ClientEvents(events => events
          .OnDataBinding("onDataBinding")
          .OnRowDataBound("onRowDataBound")
      )
    .DataBinding(d => d.Ajax().OperationMode(GridOperationMode.Client))
    .Pageable()
 %>
function onDataBinding(e) {
     var grid = $(this).data('tGrid');
        
     $('.t-status .t-icon', grid.element).addClass('t-loading');
    // call the twitter search api
    $.ajax({
        contentType: 'application/json; charset=utf-8',
        type: 'GET',
        dataType: 'jsonp',
        error: function(xhr, status) {
           alert(status);
        },
        data: {
            q: $('#searchText').val()
        },
        success: function(result) {
            grid.total = result.results.length;
            grid.dataBind(result.results);
            $('.t-status .t-icon', grid.element).removeClass('t-loading');
        }
     });
}

Regards,
Atanas Korchev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Dadv
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or