ReactJS: How to Disable toolbar from material table but not add functionality

5.3k views Asked by At

enter image description hereI want to remove toolbar, as it is creating a blank space between table and button. But as i set toolbar:false, it also disable my add new row functionality. What is the way to disable toolbar but not add functionality?

  <MaterialTable
            title=" "
           
            options={{
              search: false,
              selection: true,
              showTitle: false,
             toolbar:false,
             
            
              paging: false,
            }}
           
            columns={columns}
            data={a}
            icons={tableIcons}
            editable={{
              onRowUpdate: (newData, oldData) =>
                new Promise((resolve) => {
                  handleRowUpdate(newData, oldData, resolve);
                }),
              onRowAdd: (newData) =>
                new Promise((resolve) => {
                  handleRowAdd(newData, resolve);
                }),
              onRowDelete: (oldData) =>
                new Promise((resolve) => {
                  handleRowDelete(oldData, resolve);
                }),
            }}
          />
1

There are 1 answers

0
Piyush Priyadarshi On BEST ANSWER

I think this code snippet shall solve your problem.

<MaterialTable
  title=" "
  components={{
    Toolbar: (props) => (
      <div
        style={{
          height: "0px",
        }}
      >
        <MTableToolbar {...props} />
      </div>
    ),
  }}
  options={{
    search: false,
    selection: true,
    showTitle: false,
    toolbar: false,

    paging: false,
  }}
  columns={columns}
  data={a}
  icons={tableIcons}
  editable={{
    onRowUpdate: (newData, oldData) =>
      new Promise((resolve) => {
        handleRowUpdate(newData, oldData, resolve);
      }),
    onRowAdd: (newData) =>
      new Promise((resolve) => {
        handleRowAdd(newData, resolve);
      }),
    onRowDelete: (oldData) =>
      new Promise((resolve) => {
        handleRowDelete(oldData, resolve);
      }),
  }}
/>;