I have two dropdown
menus, one to choose the columns
of my Table
and another one to choose a filter
for this column
.
(我有两个dropdown
菜单,一个用于选择Table
的columns
,另一个用于选择此column
的filter
。)
Actually I have two functions to open both of dropdowns
(one function per dropdown
) and I would like to have just one function for both of them.(实际上,我有两个打开两个dropdowns
功能(每个dropdown
一个功能),并且我想为它们两个都只有一个功能。)
It maybe simple, but I don't know how to do it.. if someone had the solution, it would be great.(这也许很简单,但是我不知道该怎么做..如果有人有解决方案,那就太好了。)
My state:
(我的状态:)
const [anchorEl, setAnchorEl] = React.useState({
column: null,
filter: null
});
The two functions for the two dropdowns
:
(两个dropdowns
的两个功能:)
const handleClickDropdownColumn = (event) => {
setAnchorEl({
column: event.currentTarget,
});
};
const handleClickDropdownFilter = (event) => {
setAnchorEl({
filter: event.currentTarget,
});
};
And the two buttons
for open the two dropdowns
:
(和两个用于打开两个dropdowns
buttons
:)
<Button
variant="contained"
size="small"
aria-controls="simple-menu"
aria-haspopup="true"
onClick={handleClickDropdownColumn}
endIcon={<ArrowDropDownIcon/>}
>
{currentColumn}
</Button>
<IconButton onClick={handleClickDropdownFilter}>
{currentFilter}
</IconButton>
ask by Бастьен translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…