bencripps / react-redux-grid

A React Grid/Tree Component written in the Redux Pattern
http://react-redux-grid.herokuapp.com/
MIT License
446 stars 63 forks source link

Paging over local data not working #199

Open laurenga opened 6 years ago

laurenga commented 6 years ago

I built the demo code locally, changed the 'pagingType' of the PAGER to 'local' and set a 'pageSize' of 5. When I ran the modified demo the 'local' pager doesn't work. The grid only shows the first page of data.

bencripps commented 6 years ago

I think if you take a look at the simple example, you should find what you need. This uses locally paged data.

laurenga commented 6 years ago

I tried out the simple example and I've seen the documentation that notes the pagination plugin should default to enabled with a pagingType of 'local', however, this appears to be having issue.

I find that if the PAGER plugin is not specified as enabled then no paging toolbar shows up.

If I try PAGER: {enabled: true, pagingType: 'local'} then I do see the paging toolbar. When clicking next I see the PAGE_LOCAL action fired but the data in the grid doesn't change

GOVYANSONG commented 6 years ago

@laurenga I am experiencing the same issue. The PAGE_LOCAL action was dispatched properly but page did not seem to move as expected. Below is my code:

// export const BUTTON_TYPES = { NEXT: 'next', BACK: 'back' }; // const action = { index: this.state.activePage * 1 + 1, type: ReactReduxGrid.ActionTypes.PAGE_LOCAL, BUTTON_TYPES: btnTypes }; // this.context.store.dispatch ( Actions.PagerActions.setPage(action) ); @bencripps would it be possible to provide a practical example on local pagination?

GOVYANSONG commented 6 years ago

@bencripps I did more digging in the documentation and source code. My question now is: in local data mode, is stateKey required when dispatch action PAGE_LOCAL? I guess not because no parameter is reserved for it. In this light, how is local grid identified then? A bit confused

Rohmin commented 6 years ago

export const setPage = ({ index, type, BUTTON_TYPES }) => { //in this action it does not take in the state key, but from the button it is send store.dispatch( setPage({ index: pageIndex, type, BUTTON_TYPES, stateKey }) );

is this the reason that the next button on local data does not work? @bencripps It also doesnt work in the simple example, fyi.

I tried to solve this myself however I didnt understand what this reducer does, its different from how I normally make reducers in redux