question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to Change "pageSize" by code?

See original GitHub issue

I’m trying to have a little dropdownlist with different values (10,50,100) and when the user select one I would change the pagesize.

<div id="jsgrid"></div><select id="pagelength">
    <option>10</option>
    <option>50</option>
    <option>180</option>
</select>
var selectedPagelength = 15;

 $("#pagelength").change(function () {
    onPageLenghtSelect($(this).val());
});

function onPageLenghtSelect(newLenght) {
    selectedPagelength = newLenght;
    $("#instancedata-grid").jsGrid("refresh");
}

$("#instancedata-grid").jsGrid({
                autoload: true,
                sorting: true,
                paging: true,
                pageSize: selectedPagelength,
                pageButtonCount: 5,
               ....

Nothing changes. I try “render” instead of refresh… same result. If I recall my $.getJSON it works, but then I when back to the server… I don’t need calling my api to get new data I just want to change the number of line displayed.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
FBouchercommented, Nov 26, 2018

Fantastic, it works!

Here what I did:

    <span id="pageResizer" class="jsgrid-pager-page">
        <select id="pagelength">
            <option>15</option>
            <option>30</option>
            <option>60</option>
            <option>180</option>
        </select>
    </span>
    <div id="instancedata-grid"></div>

    <script type="text/javascript">
        function onPageLenghtSelect(newLenght) {
            selectedPagelength = newLenght;
            $("#instancedata-grid").jsGrid("changePageSize", selectedPagelength);
        }

        $("#instancedata-grid").jsGrid({
            autoload: true,
            sorting: true,
            paging: true,
            pageSize: selectedPagelength,
            pageButtonCount: 5,
            changePageSize: function (pageSize) {
                var $this = this;
                $this.pageSize = selectedPagelength;
                $this.refresh();
            },
            ...
        });

        $("#pageResizer").prependTo(".jsgrid-pager");
    </script>
0reactions
FBouchercommented, Nov 26, 2018

Yeah that’s what I did. Bad copy paste. and I used the pagerContainer: property instead of the jquery to get the dropdown inside the pager section.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set DataPager pagesize in codebehind. - MSDN
DataPager1.PageSize = 10;. Hi, I have tried setting the pager pagesize property to 1. And then in the codebehind, I added for example,...
Read more >
Change PDF Page Size Programmatically|Aspose.PDF for Java
PDF for Java lets you change PDF page size with simple lines of code in your Java applications. This topic explains how to...
Read more >
How to change dynamically the value in pageSize in Material ...
Hi guys. I'm working in a project where the default value for the pageSize is a fixed number. Now, I need change this...
Read more >
angular - How to change the text in the label in pagination?
For label for the page size selector. I tried to do it but did not help: <mat-paginator [pageSizeOptions]="[5, 10, 20]" ...
Read more >
HTML vs Body: How to Set Width and Height for Full Page Size
This can be counterintuitive and confusing. For a responsive full page height, set the body element min-height to 100vh. If you set a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found