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

[Solved] Paging on Ajax Grid

4 Answers 136 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.
Jamie
Top achievements
Rank 1
Jamie asked on 24 Sep 2010, 10:21 PM
Is there a way to manually set paging on a grid?  I'm using onDataBinding to call an ajax function, which then calls grid.dataBind with the results.  The controller only returns the number of results that can be displayed on one page of the grid, as json results can't be IQueryable.  And the paging always says 0 of 0 results.

So, is there a way to say "the grid has 5000 records, and you're on page 6" programmatically?  Or should I just hide the paging control and roll my own?

If it helps at all, here's the function that gets called from onLoad and onDataBinding:

function populateGrid(entity, searchColumn, searchText) {
    var grid = $('#' + entity + '_grid').data('tGrid');
    var searchMethod = 'gridlist';

    $('.t-status .t-icon', grid.element).addClass('t-loading');

    $.ajax({
        url: '/json/' + entity + '/' + searchMethod + '?',
        data: { field: searchColumn, value: searchText },
        error: function (xhr, status) {
            alert(status);
        },
        success: function (data) {
            grid.dataBind(data);
            $('.t-status .t-icon', grid.element).removeClass('t-loading');
        }
    });
}

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 27 Sep 2010, 08:46 AM
Hello Jamie,

You can try updating the currentPage and total fields of the grid before calling the dataBind method:

grid.currentPage = 2;
grid.total = 100;
grid.dataBind(data);

I hope this helps,
Atanas Korchev
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
0
Jamie
Top achievements
Rank 1
answered on 27 Sep 2010, 07:18 PM
That's perfect.  Just one more question... how I do I access the paging controls, so when they click forward or a page number, I can capture that on the client?  Like onPaging or something?

If you want to point me in the direction of the api I'd be happy to research on my own. I'm just having a really hard time finding any documentation on the MVC api...
0
Atanas Korchev
Telerik team
answered on 28 Sep 2010, 08:36 AM
Hello Jamie,

 You can use the onDataBinding client event and access the currentPage field from there. It should be properly updated.

Regards,
Atanas Korchev
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
0
Houssam Hamdan
Top achievements
Rank 1
answered on 15 Jun 2011, 07:02 AM
Hi Atanas,

grid.currentPage = 2;
grid.total = 100;
grid.dataBind(data);

The above code updates the paging parameters successfully but it always show the data of currentPage = 1. Any idea why this could be happening?

Thx in advance.
Tags
Grid
Asked by
Jamie
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Jamie
Top achievements
Rank 1
Houssam Hamdan
Top achievements
Rank 1
Share this question
or