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

[Solved] Change page size or pageable option client side

4 Answers 214 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.
Travis
Top achievements
Rank 1
Travis asked on 11 Apr 2012, 10:36 PM
I have a grid using ajax binding and I want to either remove the pageable option so that there is no longer paging, or change the page size to something like 1000.  Is this possible?

4 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 13 Apr 2012, 08:44 AM
Hi Travis,

Surely you can disable paging if you want, by removing the Pageable() setting from the Grid declaration. You can also control the PageSize, either in the declaration, or client-side via a dropdown. Please review the Paging demo and its description. We have also a Paging documentation article. Note that having too many records displayed by the browser may impose performance hit on the client machine. Every hardware has its limits. You can consider using PageOnScroll (virtualization).

Regards,
Dimo
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.
0
Travis
Top achievements
Rank 1
answered on 17 Apr 2012, 06:09 PM
This isn't working, although, most likely because my code is not the same as your example.  I'm trying to set the paging option by binding the grid using ajaxRequest() or rebind() instead of submitting all form data again with a submit button.  Here's my grid:

@(Html.Telerik().Grid<HelpDeskDAL.ActivityLog>()
       .Name("ActivityLogGrid")
       .DataKeys(keys => keys.Add(p => p.ActivityLogID).RouteKey("ActivityLogID"))
       .Columns(columns =>
       {
           columns.Bound(o => o.UpdateDate)
               .Title("Date")
               .Width("150px")
               .Format("{0:M/d/yyyy hh:mm tt}");
           columns.Bound(o => o.UpdateUser)
               .Width("75px")
               .Title("User");
           columns.Bound(o => o.LogText)
               .Title("Description")
               .ClientTemplate(Server.HtmlDecode("<#= LogText #>"));
       })
       .DataBinding(dataBinding => dataBinding.Ajax()
           .Select("_SelectActivityLog", "Home"))
       .ClientEvents(events => events.OnDataBinding("onActivityLogDataBinding"))
       .Pageable(ps=>ps.PageSize(Int32.Parse(ViewData["LogPageSize"].ToString())))
       .Sortable(sorting => sorting.OrderBy(sortOrder => sortOrder.Add(o => o.UpdateDate).Descending()))

And my databinding event that is setting the paging option:
var ActivityLogPageSize=10;
function onActivityLogDataBinding(e) {
    var filter = {RequestID: viewModel.RequestID(),PageSize:ActivityLogPageSize};
    e.data = filter;
}

My controler select binding event

[GridAction]
public ActionResult _SelectActivityLog(int? RequestID,int PageSize)
{
    ViewData["LogPageSize"] = PageSize;
    return View(new GridModel<ActivityLog>
    {
        Data = db.ActivityLogs()
    });
}

My ajaxRequest function that is changing the page size:

function PrintRequest() {
        ActivityLogPageSize=1000;
        $("#ActivityLogGrid").data('tGrid').ajaxRequest(); //rebind doesn't work either
}

Is this not possible?  Can I set the pagesize option somehow on my databinding event?

0
Accepted
Dimo
Telerik team
answered on 18 Apr 2012, 11:45 AM
Hi Travis,

Changing the pageSize in the dataBinding event is too late, moreover, I don't see how setting the value of an independent variable in the PrintRequest function will influence the pageSize. You can do this:

var grid = $("#Grid").data("tGrid");
grid.pageSize = 20;
grid.ajaxRequest();


Regards,
Dimo
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.
0
Travis
Top achievements
Rank 1
answered on 18 Apr 2012, 03:25 PM
Thank you!  I had tried something like that earlier, but it wasn't working for different reasons. 
Tags
Grid
Asked by
Travis
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Travis
Top achievements
Rank 1
Share this question
or