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

Disable paging when only 1 page

3 Answers 712 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lennart
Top achievements
Rank 1
Lennart asked on 10 Jan 2013, 03:33 PM
Hi all,

I was wondering if it was possible to disable/hide the paging feature dynamically when only 1 page is shown, i.e. PageSize is set to 100, but the data only consists of 70 rows.

Thanks!

Lennart

3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 14 Jan 2013, 08:13 AM
Hello Lennart,

You can hide the pager when total pages in the data source is one. For example:
//get reference to the Grid
var grid = $(".k-grid").data("kendoGrid");
 
grid.bind("dataBound", function() {
 if (this.dataSource.totalPages() == 1) {
  this.pager.element.hide();
 }
});


Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Lennart
Top achievements
Rank 1
answered on 14 Jan 2013, 01:40 PM
Hi,

The solution you proposed did not work for me, but thanks for helping me get on my way. I ended up doing this:

In the grid definition:
.Events(events => events
  .DataBound("GridDataBound")
)
And then in JavaScript:
function GridDataBound() {
    if (this.dataSource.totalPages() == 1) {
        this.pager.element.hide();
    }
}
Thanks again!
0
Timothy
Top achievements
Rank 1
answered on 26 Aug 2016, 08:25 AM
A much cleaner fix that doesn't need any javascript at all - use this css. This basically just hides the page number if it's the only one on the page.

.k-pager-numbers li:nth-child(2):last-child { display:none; }
Tags
Grid
Asked by
Lennart
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Lennart
Top achievements
Rank 1
Timothy
Top achievements
Rank 1
Share this question
or