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

How to show all records in a grid (PageSize)

6 Answers 1315 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vlad
Top achievements
Rank 1
Vlad asked on 11 Oct 2012, 02:13 AM
Hi,

I need to show all records in a grid, so no paging.  By default grid uses paging (10 records).  Is there any property that can turn off paging?

I tried to use PageSize(-1), but I got "NaN - NaN of 50 records", so it actually disabled paging but gave me "NaN - NaN".  I tried PageSize(0) and it works same way as PageSize(10).

So what I've end up doing  is entering 1000000 value in to PageSize property.  It works, but I don't like this approach.  Is there is a right way of doing it?

Thanks a lot.

Sincerely,
Vlad.

.Sortable()
.Scrollable()
.ColumnMenu()
.Pageable(x =>
    {
        x.Enabled(true);
        x.PreviousNext(false);
        x.PageSizes(false);
        x.Info(true);
        x.Input(false);
        x.Numeric(false);
        x.Refresh(true);
    })
.Resizable(resize => resize.Columns(true))
.Reorderable(reoder => reoder.Columns(true))
.DataSource(ds => ds.Ajax()
                      .ServerOperation(false)
                      .PageSize(1000000)
                      .Events(events => events.Error("error"))
                      .Read(read => read.Action("TodayOrders", "Orders")))

6 Answers, 1 is accepted

Sort by
0
Muthu
Top achievements
Rank 1
answered on 11 Oct 2012, 05:05 AM
what happen if u remove Pageable()?
0
Vlad
Top achievements
Rank 1
answered on 11 Oct 2012, 12:23 PM
Thanks Muthu for your reply.

Unfortunately I need to keep Pageable() because I need to show status bar with records counter and I need to have refresh button on it.  And the only way of doing that is to have Pageable().

Thanks again.

Sincerely,
Vlad.
0
Jose
Top achievements
Rank 1
answered on 21 Feb 2013, 07:19 PM
I know that the post is a little bit old, but just in case...

.DataSource(ds => ds.Ajax() // o Server()
.PageSize(Model.Count()) // Gets the total of records/rows/items if your model is an Array, IQueryable, IEnumerable, etc...
)

=)


Posted 0 minutes ago (permalink)

I know that the post is a little bit old, but just in case...

You can put the IF statement in your Controller

int pageSize = 0;

if (Request.Browser.MobileDeviceModel != "IPad")
pageSize = 200;
else
pageSize = 20;

and finally send it using ViewBag dictionary...

ViewBag.PageSize = pageSize;

---

// View ----

.DataSource(ds => ds.Ajax() // or Server()
.PageSize((int) ViewBag.PageSize)
)

=)

Posted 0 minutes ago (permalink)

I know that the post is a little bit old, but just in case...

You can put the IF statement in your Controller

int pageSize = 0;

if (Request.Browser.MobileDeviceModel != "IPad")
pageSize = 200;
else
pageSize = 20;

and finally send it using ViewBag dictionary...

ViewBag.PageSize = pageSize;

---

// View ----

.DataSource(ds => ds.Ajax() // or Server()
.PageSize((int) ViewBag.PageSize)
)

=)
0
Raymond
Top achievements
Rank 1
answered on 30 Sep 2013, 01:10 AM
Just a caveat to look for.  
I had written a wrapper function to set a number of grid settings, including pagesize, at once.  I found by accident that with the pagesize set at 0 the filtering stops working (ver 2013.2.918)  The grid data would display, but if I tried to set a filter on a boolean column all data would disappear and not reappear if I cleared the filter.
0
Mike
Top achievements
Rank 1
answered on 17 Dec 2013, 12:37 AM
How can this be done with the non-MVC version? I tried by using adding datasource.total() into the pageSizes array and it doesn't seem to work. The dropdown displays 0 and when selected it shows the datasource.total() value. However, 0 rows are displayed in the grid.
0
Alexander Valchev
Telerik team
answered on 19 Dec 2013, 10:13 AM
Hi Sean,

PageSizes array expects array of numbers. If your scenario involves remote data, most probably at the time when pager is initialized the data and respectively the total number of records will not be received on the client.
My recommendation is to put a separate button which will be responsible for showing all records. On click of the button all you need to do is to set the pageSize to dataSource.total().
var dataSource = $("#grid").data("kendoGrid").dataSource,
    total = dataSource.total();
 
dataSource.pageSize(total);


Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Vlad
Top achievements
Rank 1
Answers by
Muthu
Top achievements
Rank 1
Vlad
Top achievements
Rank 1
Jose
Top achievements
Rank 1
Raymond
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Alexander Valchev
Telerik team
Share this question
or