Material-table: Default options for all tables

Created on 28 Jun 2020  路  2Comments  路  Source: mbrn/material-table

I want to apply the specific options to all tables in application.
How I do?

For example:
All Material Tables hav such options

        options={{
          showTitle: false,
          padding: 'dense',
          pageSize: 10,
          pageSizeOptions: [10, 20, 50],
          headerStyle: {
            backgroundColor: 'transparent',
            fontWeight: 'bold',
          }
        }}
question

All 2 comments

Hi @watanabeshuji,

to have a default options in all tables you can import a var configuration and use the property spread notation (It was added in ES2018).

Your table configuration

export const TableDefaultConfig = {
       options: {
           showTitle: false,
           padding: 'dense',
           pageSize: 10,
           pageSizeOptions: [10, 20, 50],
           headerStyle: {
              backgroundColor: 'transparent',
              fontWeight: 'bold',
          }
      }
}

Your page with table

import { TableDefaultConfig } from '../TableConfig';

<MaterialTable 
   options={{
       ...TableDefaultConfig.options,
       pageSize: 20, 
   }}
/>

thank a lot!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

revskill10 picture revskill10  路  3Comments

ps1011 picture ps1011  路  3Comments

jlgreene2 picture jlgreene2  路  3Comments

diegosps picture diegosps  路  3Comments

ModPhoenix picture ModPhoenix  路  3Comments