[英]How can I change remove the filter icon when using the material-table library?
我想刪除過濾器圖標,只保留空白輸入框。 我嘗試使用列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);
顯然,您可以使用圖標prop刪除任何圖標,並將空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
}}
/>
)
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.