简体   繁体   English

material-ui/Table如何让一栏文字自动换行? 默认使用省略号

[英]How does material-ui/Table make one column of text wrap automatically? The ellipsis is used by default

The ellipsis is used by default, but I want it to wrap automatically.默认情况下使用省略号,但我希望它自动换行。 thank you very much!!!非常感谢你!!! 省略 在此处输入图像描述

I used the material-ui framework for the first time and checked some cases on the Inte.net.第一次使用material-ui框架,上网查了一些案例。 I checked the official document https://material-ui.com/components/tables/ but I still have no idea.查了官方文档https://material-ui.com/components/tables/还是没有头绪。 Maybe my method is wrong.也许我的方法不对。

code show as below:代码如下:

import {
  Table,
  TableBody,
  TableHeader,
  TableHeaderColumn,
  TableRow,
  TableRowColumn,
} from 'material-ui/Table';

getTable() {
    let rows = [];
    for(var i=0; i<this.state.tasksOnShow.length; i++){
      let row = this.state.tasksOnShow[i];
      rows.push(
        <TableRow key={"row"+row.planId}>
          <TableRowColumn>{row.level}</TableRowColumn>
          <TableRowColumn>{row.taskName}</TableRowColumn>
          <TableRowColumn>{row.owner}</TableRowColumn>
          <TableRowColumn>{row.taskType}</TableRowColumn>
          <TableRowColumn>{row.taskGroup}</TableRowColumn>
          <TableRowColumn>{row.projectTeam}</TableRowColumn>
          <TableRowColumn>{row.status}</TableRowColumn>
        </TableRow>
      );
    }
    let styles = {
      tdStyle1:{
        width: "5%"
      },
      tdStyle2:{
        width: "30%"
      },
      tdStyle3:{
        width: "15%"
      },
      tdStyle4:{
        width: "10%"
      },
      tdStyle5:{
        width: "12%"
      },
      tdStyle6:{
        width: "12%"
      },
      tdStyle7:{
          width: "16%"
      }
    }
    return (
      <div>
        <Table
          height={450}
          fixedHeader={false}
          fixedFooter={false}
          selectable={true}
          multiSelectable={true}
          onRowSelection={(sels)=>this.onRowSelection(sels)}
        >
          <TableHeader
            displaySelectAll={true}
            adjustForCheckbox={true}
            enableSelectAll={true}

          >
            <TableRow>
              <TableHeaderColumn style={styles.tdStyle1} tooltip="level">level</TableHeaderColumn>
              <TableHeaderColumn style={styles.tdStyle2} tooltip="taskName">taskName</TableHeaderColumn>
              <TableHeaderColumn style={styles.tdStyle3} tooltip="owner">owner</TableHeaderColumn>
              <TableHeaderColumn style={styles.tdStyle4} tooltip="taskType">taskType</TableHeaderColumn>
              <TableHeaderColumn style={styles.tdStyle5} tooltip="taskGroup">taskGroup</TableHeaderColumn>
              <TableHeaderColumn style={styles.tdStyle6} tooltip="projectTeam">projectTeam</TableHeaderColumn>
              <TableHeaderColumn style={styles.tdStyle7} tooltip="status">status</TableHeaderColumn>
            </TableRow>
          </TableHeader>
          <TableBody
            displayRowCheckbox={true}
            deselectOnClickaway={false}
            showRowHover={true}
            stripedRows={true}
          >
          {rows}

          </TableBody>
        </Table>
      </div>
    );

You can try to make it wrap using word-break您可以尝试使用word-break使其换行

tdStyle2:{
  width: "30%",
  wordBreak: "break-all"
},

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM