hyojin / material-ui-datatables

An another React Data tables component.
MIT License
165 stars 58 forks source link

Row Selection does not work with pagination. #57

Closed waqaskhan-zs closed 7 years ago

waqaskhan-zs commented 7 years ago
<DataTables
          height={'auto'}
          columns={TABLE_COLUMNS}
          data={TABLE_DATA}
          selectedRows={this.state.selectedMachines}
          onRowSelection={this.rowSelection}
          showRowHover
          multiSelectable
          selectable
          showCheckboxes
          count={this.props.machineList.length}
          page={this.state.page}
          onRowSizeChange={this.onRowSizeChange}
          onNextPageClick={this.onNextPage}
          onPreviousPageClick={this.onPrevPage}
          rowSize={this.state.rowSize}
        />

in props onRowSelection the handler gets the index of the selected row, and when the page is changed the row is still selected, because the rows indexes will always be the same, where as the after the next page the data has changed. Am I missing something or do i have the configurations wrong? Any suggestions would be helpful. just a note: pagination works fine, everything else works fine just the row selection is a problem.

hyojin commented 7 years ago

@waqaskhan-zs It seems like you're using selectedRows prop to manage it programmatically. If you don't have specific reason, just remove it

waqaskhan-zs commented 7 years ago

@hyojin I am using selectedRows to show rows that are preselected when that component is loaded.

Thanks for replying

hyojin commented 7 years ago

@waqaskhan-zs then why don't you change your state, this.state.selectedMachines, in your pagination event handlers?

waqaskhan-zs commented 7 years ago

That's what i have done, but i was hoping the component would manage the selected machines.