【问题标题】:Material-table ReactJs toggle detailPanel open/closing from actions材料表ReactJs切换detailPanel从动作打开/关闭
【发布时间】:2020-06-24 19:31:54
【问题描述】:

有没有办法通过操作列中的 onClick() => {} 操作来控制材料表中 detailPanel 的打开/关闭?

【问题讨论】:

    标签: reactjs material-table


    【解决方案1】:

    最终我通过关注thread 使其工作

    export class Services extends React.Component {
       constructor() {
          super();
       }
       this.tableRef = React.createRef();
    
       render() {
           
          return (
             <MaterialTable
              tableRef={this.tableRef}
              icons={tableIcons}
              title= 'Service catalog table'
              columns={[{ title: "Service Name", field: "nom_service", editable: 'never'}]}
              actions={[
                 (rowData) => {
                    return ({
                      onClick: (event, rowData) => { 
                         this.tableRef.current.onToggleDetailPanel( [rowData.tableData.id],
                         this.tableRef.current.props.detailPanel[0].render)
                      }
                  })}
                   
              ]}
    
              detailPanel={[
                {
                  icon: ()=> null,
                  openIcon: ()=> null,
                  disabled:true,
                  render: rowData => {
                  
                    return (<p>{rowData.nom_service}</p>)
                  }
                 }  
                
              ]}
          )
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-05
      • 1970-01-01
      • 2021-02-02
      • 1970-01-01
      • 2017-03-23
      • 2018-12-02
      相关资源
      最近更新 更多