4

Can i customize appearance of a Grid's pager? I wanna select a page size from list (like Redmine, see 'Per page' block) not from dropdown.

It's standart Telerik's pager:

Standart Telerik's pager

It's Redmine's pager:

Redmine pager

Thanks.

PS for instance Devexpress' Grid has this ability

vladimir
  • 13,428
  • 2
  • 44
  • 70
  • ahhh...I hope telerik developers to be a little faster in adding new features. DevExpress is now great at this time(specially in grid related technologies). Maybe I emigrate to DevExpress finally in my new projects. – Mahmoud Moravej Feb 02 '12 at 16:33
  • 1
    Have you seen custom paging in online example it may help http://demos.telerik.com/aspnet-mvc/grid/custombinding – Tassadaque Feb 04 '12 at 22:50
  • Tassadaque, yes - i've seen it and using it :) Unfortunately custom binding doesnt correlate with custom pager :( – vladimir Feb 06 '12 at 17:02

1 Answers1

1

You could replace the DOM element that is responsible for page size. You need to do it when grid is loaded.

View

@Html.Telerik().Grid(Model)
    .Name("Grid")
    .ClientEvents(events => events.OnLoad("Grid_onLoad"))

JavaScript

function Grid_onLoad(e)
{
    var html = { place your favorite template engine here }
    $('#YourGridId').find('.t-page-size').html(html);
    // bind 'click' event to your new control
}

Now the problem is that you need to bind own event to the change of the page size and tell new page size for the Telerik grid.

You can provide additional parameters to the controller action that provides data to your controller. There is an example in the documentation how to add additional data to your request.

<script type="text/javascript">
function Grid_onDataBinding(e) {

    // pass additional values by setting the "data" field of the event argument
    e.data = {
        pageSize: // TODO: provide selected page size from your new control
    };
}
</script>

In the server side controller action should automatically map your pageSize to an action parameter.

I hope this helps, let me know if you need more information.

Tx3
  • 6,796
  • 4
  • 37
  • 52