grid-js / gridjs

Advanced table plugin
https://gridjs.io
MIT License
4.39k stars 241 forks source link

Pagination selector #328

Open andresfdel17 opened 3 years ago

andresfdel17 commented 3 years ago

Hello, i need a pagination record selector please. i work with a lot of records and i want than my clients can choose te rows: Like this

pagination = {
      enabled: true,
      limit:[10,25,50,100],
      resetPageonUpdate: false
    };

or this

pagination = {
      enabled: true,
      limit:() => {
//here goes function to call a selector value
},
      resetPageonUpdate: false
    };
afshinm commented 3 years ago

Good suggestion @andresfdel17. The current page size is static https://gridjs.io/docs/config/pagination. I can work on adding that feature.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

pcambra commented 3 years ago

It'd be also great if that setting was able to be exposed close to the search input :)

r14n commented 1 year ago

Need this!

xHeaven commented 1 year ago

Just fyi, you can do this:

const grid = new Grid({
    // ...
}).render(wrapper);

const limitRecords = document.querySelector("#limit-records");
limitRecords?.addEventListener('change', () => {
    grid?.updateConfig({
        pagination: {
            limit: parseInt(limitRecords.value)
        }
    }).forceRender();
});

It's a bit hacky, but better than nothing.

aswzen commented 1 year ago

Really need this

monkekode commented 10 months ago
const limitRecords = document.querySelector("#limit-records");
limitRecords?.addEventListener('change', () => {
  grid?.updateConfig({
      pagination: {
          limit: parseInt(limitRecords.value)
      }
  }).forceRender();
});

This didn't work for me (gave duplicate pagination plugin error), but this did:

        grid.config.pagination.limit = e.target.value;
        grid.forceRender();