简体   繁体   English

添加一个按钮来反应材料表工具栏

[英]Add a button to react material-table toolbar

I want to add a button to material-table toolbar.我想在材料表工具栏上添加一个按钮。 it doesnt do anything relevant to the table.它不做任何与表格相关的事情。 it just opens a modal with some information它只是打开一个带有一些信息的模式

I want to add a button called "quotations" to the left side of the "add item" button.我想在“添加项目”按钮的左侧添加一个名为“引用”的按钮。

在此处输入图片说明

Sandbox code: https://codesandbox.io/embed/charming-yalow-4pnk4?fontsize=14&hidenavigation=1&theme=dark沙盒代码: https : //codesandbox.io/embed/charming-yalow-4pnk4? fontsize =14& hidenavigation =1& theme =dark

Per the docs, it looks like you need to override the Toolbar component of your table and you should be able to add what ever you want above the column headers:根据文档,您似乎需要覆盖表格的 Toolbar 组件,并且您应该能够在列标题上方添加任何您想要的内容:

https://material-table.com/#/docs/features/component-overriding https://material-table.com/#/docs/features/component-overriding

https://i.stack.imgur.com/J0mqf.png https://i.stack.imgur.com/J0mqf.png

As Will Evers mentioned, it's possible to add whatever is necessary to Toolbar of the MaterialTable component by using Toolbar prop :正如威尔·埃弗斯提到,有可能添加任何必要Toolbar的的MaterialTable使用组件Toolbar道具:

          Toolbar: (props) => (
            <div
              style={{
                display: "flex",
                justifyContent: "flex-end",
                alignItems: "center"
              }}
            >
              <Button
                style={{ height: "fit-content" }}
                color="primary"
                variant="contained"
              >
                Quotations
              </Button>
              <div style={{ width: "13rem" }}>
                <MTableToolbar {...props} />
              </div>
            </div>
          ),

Working Demo 工作演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM