gpt4 book ai didi

javascript - 使用 Material 表库时如何更改删除过滤器图标?

转载 作者:行者123 更新时间:2023-11-30 11:02:16 25 4
gpt4 key购买 nike

我想删除过滤器图标,只有空白输入框。我试过使用列 Prop filterCellStyle但无法访问该图标,因为它是内联样式。


import React, { Children } from "react";
import ReactDOM from "react-dom";
import MaterialTable from 'material-table';

class Example extends React.Component {
render() {
return (
<MaterialTable
title="Non Filtering Field Preview"
columns={[
{ title: 'Name', field: 'name', filterCellStyle: {
background: "red"
}},

{ title: 'Surname', field: 'surname' },
{ title: 'Birth Year', field: 'birthYear', type: 'numeric' },
{
title: 'Birth Place',
field: 'birthCity',
lookup: { 34: 'İstanbul', 63: 'Şanlıurfa' },
},
]}
data={[
{ name: 'Mehmet', surname: 'Baran', birthYear: 1987, birthCity: 63 },
{ name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34 },
]}
options={{
filtering: true
}}

/>
)
}
}

const rootElement = document.getElementById("root");
ReactDOM.render(<Example />, rootElement);

最佳答案

显然你可以使用 icons 属性来删除任何图标并将一个空的 div 元素传递给图标:


import React, { Children } from "react";
import ReactDOM from "react-dom";
import MaterialTable from 'material-table';

class Example extends React.Component {
render() {
return (
<MaterialTable
icons={{ Filter: () => <div /> }} // <== this solves it
title="Non Filtering Field Preview"
columns={[
{ title: 'Name', field: 'name', filterCellStyle: {
background: "red"
}},

{ title: 'Surname', field: 'surname' },
{ title: 'Birth Year', field: 'birthYear', type: 'numeric' },
{
title: 'Birth Place',
field: 'birthCity',
lookup: { 34: 'İstanbul', 63: 'Şanlıurfa' },
},
]}
data={[
{ name: 'Mehmet', surname: 'Baran', birthYear: 1987, birthCity: 63 },
{ name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34 },
]}
options={{
filtering: true
}}

/>
)
}
}

关于javascript - 使用 Material 表库时如何更改删除过滤器图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57191145/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com