【问题标题】:Is there a way to change the toolbar button name in DataGrid?有没有办法更改 DataGrid 中的工具栏按钮名称?
【发布时间】:2021-11-28 08:47:14
【问题描述】:

我已经制作了一个自定义工具栏

function CustomToolbar() {
  return (
    <GridToolbarContainer>
      <GridToolbarColumnsButton />
      <GridToolbarFilterButton />
      <GridToolbarDensitySelector />
      <GridToolbarExport />
    </GridToolbarContainer>
  )
}

但我想在显示时更改名称,而不是 Columns、Filters、Density、Export,有什么解决办法吗?

【问题讨论】:

    标签: reactjs material-ui material-ui-x


    【解决方案1】:

    您可以更改DataGrid/DataGridProlocaleText 属性,查看所有翻译键及其默认值here

    <DataGrid
      {...data}
      localeText={{
        toolbarColumns: "my columns",
        toolbarFilters: "my filters",
        toolbarDensity: "my density",
        toolbarExport: "my export"
      }}
      components={{
        Toolbar: CustomToolbar
      }}
    />
    

    【讨论】:

    • 非常感谢,为此苦苦挣扎了好几个小时
    • 完成了,我是新来的,是的,它解决了问题,再次感谢!
    猜你喜欢
    • 2017-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-08
    • 1970-01-01
    相关资源
    最近更新 更多