material-table icon indicating copy to clipboard operation
material-table copied to clipboard

components.Pagination labelRowsPerPage overwritten by localization

Open 0x-2a opened this issue 7 years ago • 4 comments

Describe the bug

This problem came up for me when following the advice from https://github.com/mbrn/material-table/issues/148#issuecomment-452984812, referencing this line material-table.js:449. LabelDisplayedRows and labelRowsPerPage don't work anymore.

For example:

// import { TablePagination } from '@material-ui/core';

<MaterialTable
  columns={[]}
  data={this.state.data}
  title='Demo Title'

  // ******** Some workarounds can happen out here now *******
  localization={{
    pagination: {
      labelDisplayedRows: 'string here'
      labelRowsPerPage: 'another string here'
    }
  }}
  // ********

  components={{
    Pagination: props => (
        <TablePagination
            {...props}

            // ******* These don't work anymore, because overwritten ********
            labelRowsPerPage={<div style={{fontSize: 14}}>{props.labelRowsPerPage}</div>}
            labelDisplayedRows={row => <div style={{fontSize: 14}}>{props.labelDisplayedRows(row)}</div>}
            // ******* 
        />
    )
  }}
/>;

Related issues: https://github.com/mbrn/material-table/issues/148, https://github.com/mbrn/material-table/issues/226

0x-2a avatar Aug 06 '19 16:08 0x-2a

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. You can reopen it if it required.

stale[bot] avatar Jun 15 '20 16:06 stale[bot]

I have the same issue ...At least I saw labelDisplayedRows={row => <div style={{fontSize: 14}}>{props.labelDisplayedRows(row)}</div>} does not change the table rendering. Could this still be an ongoing issue?

cristiangabor avatar Jun 17 '20 23:06 cristiangabor

I have the same issue. My function is being invoked and is returning the desired text, but not showing up in the rendered component.

[Edit] Should perhaps mention my goal in doing this. I'd like to format large count values i.e. 1,000 instead of 1000. Easy enough to do with a custom labelDisplayedRows, but since its output is being discarded/ignored, I am unable to format the count as desired.

bargar avatar Jun 26 '20 22:06 bargar

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. You can reopen it if it required.

stale[bot] avatar Sep 25 '20 00:09 stale[bot]