react-redux-grid icon indicating copy to clipboard operation
react-redux-grid copied to clipboard

Edit pageSize number

Open Kamou31 opened this issue 7 years ago • 5 comments

Hello,

I'm trying to give users the ability to change the pageSize of the grid. I created a state variable : itemsDisplayed. The value is well modified by other part of my code. But unfortunately, even if the render function is called after the update of this state value, the number of items that my grid displays on each page doesn't change.

Here's my code :

       var itemsNumber = 5;
        if (this.state.itemsDisplayed) {
            itemsNumber = this.state.itemsDisplayed;
        }
        console.log(itemsNumber); // Display 5 then 6 then 7 then 8 after my setState
        const gridData = {
            columns,
            data: data,
            pageSize: itemsNumber,
            plugins: plugins,
            events,
            height: this.state.height,
            stateKey: 'events'
        };

The console proves that my itemsNumber is well updated but the grid always display only the first 5 items as it was defined the first time.

Can you help me? Thank you very much !

Kamou31 avatar Aug 25 '17 13:08 Kamou31

I would take a look at the bulk selection example, which is dynamically changing what the pageSize. Here is the code, and here is the actual live example.

bencripps avatar Aug 25 '17 13:08 bencripps

Thank you. I'll try to understand it and I'll keep you in touch.

Kamou31 avatar Aug 25 '17 13:08 Kamou31

Thank you, didn't understant the utility of getAsyncData but now it's ok !

Thank you for your help

Kamou31 avatar Aug 25 '17 15:08 Kamou31

Indeed, it works, but in the example (like in my code) the sorting parameter isn't kept after the getAsyncData. Is there a way to keep it ? Or to re-apply it ?

Thank you very much

Kamou31 avatar Aug 28 '17 09:08 Kamou31

@bencripps a question: does change page size work with local data? The example is for remote data.

GOVYANSONG avatar Feb 23 '18 21:02 GOVYANSONG