gpt4 book ai didi

reactjs - 如何在React固定数据表单元格内使用material-ui IconMenu

转载 作者:行者123 更新时间:2023-12-03 13:20:52 31 4
gpt4 key购买 nike

我已经整理了网格的工作示例,并希望将 IconMenu 添加到网格每一行的列中。我看到图标按钮,但当我单击它时,我没有看到菜单。下面是网格的代码。

有人设法获得 fixed-data-tableIconMenu from material-ui 合作?

require('fixed-data-table/dist/fixed-data-table.css');

var React = require('react');
var PropTypes = React.PropTypes;
var FixedDataTable = require('fixed-data-table');
var Table = FixedDataTable.Table;
var Column = FixedDataTable.Column;

// Material-UI
let MenuItem = require('material-ui/lib/menus/menu-item');
let IconMenu = require('material-ui/lib/menus/icon-menu');
let IconButton = require('material-ui/lib/icon-button');
let Colors = require('material-ui/lib/styles/colors');
let MoreVertIcon = require('material-ui/lib/svg-icons/navigation/more-vert');

function cellMenuRenderer(cellData, key, rowData, rowIndex, columnData, width) {
let button = (
<IconButton
touch={true}
tooltip='Click to see menu.'
tooltipPosition='bottom-left'>
<MoreVertIcon color={Colors.grey400} />
</IconButton>
);
return (
<IconMenu iconButtonElement={button}>
<MenuItem primaryText="Edit" />
<MenuItem primaryText="New Test" />
<MenuItem primaryText="Review" />
</IconMenu>
);
}

var SampleResultGrid = React.createClass({
propTypes: {
onContentDimensionsChange: PropTypes.func,
left: PropTypes.number,
top: PropTypes.number
},

getInitialState() {
var jsonText = '[{"First":"Joe","Last":"Smith","Company":"Joe\'s Garage","Email":"joe@smith.com"},{"First":"Jill","Last":"Smithers","Company":"Jill\'l Rehab Center","Email":"jill@smithers.com"},{"First":"Brenda","Last":"Jones","Company":"Foodmart","Email":"brenda@jones.com"}]';
let data = JSON.parse(jsonText);
console.log(data);
return {
rows: data
};
},

rowGetter(index) {
return this.state.rows[index];
},

render() {
return (
<Table
headerHeight={40}
rowHeight={30}
rowsCount={this.state.rows.length}
rowGetter={this.rowGetter}
width={800}
height={500}>
<Column
width={100}
cellRenderer={cellMenuRenderer}
align='center'
dataKey='Menu'
label='Menu'/>
<Column
width={150}
dataKey='First'
label='First'/>
<Column
width={150}
dataKey='Last'
label='Last'/>
<Column
width={150}
dataKey='Company'
label='Company'/>
<Column
width={150}
dataKey='Email'
label='Email'/>
</Table>
);
}
});

module.exports = SampleResultGrid;

最佳答案

require('fixed-data-table/dist/fixed-data-table.css');

你必须在加载 React 组件的 html 页面中提供此 css 引用是行不通的。

关于reactjs - 如何在React固定数据表单元格内使用material-ui IconMenu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31726079/

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