首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我们可以在react数据表组件的一列下使用两个选择器吗?

我们可以在react数据表组件的一列下使用两个选择器吗?
EN

Stack Overflow用户
提问于 2021-01-12 15:09:04
回答 1查看 1K关注 0票数 0

我正在使用react数据表组件,我想在一个标题下显示2个字段。但问题是我不知道使用react-data-table-component的正确方法,react-data-table-component的指令没有包含这样的例子。

所以我想知道我们是否可以在一列下使用两个选择器。

下面是我的代码:

代码语言:javascript
复制
{
  name:<div style={{ cursor: 'context-menu' , marginRight:'80px'}}>Implementation</div>,
  selector: 'ImplementationStatus',
  selector: 'DoneDate',

  ignoreRowClick: true,
  cell: row => (
  <div>
  <div style={{display: 'inline-block',marginRight:'10px',color:row.ImplementationStatus == 0 ? "red" : (row.ImplementationStatus == 1 ? "#fe9810" : (row.ImplementationStatus == 2 ? "green" : "black"))}}>{row.ImplementationStatus == 0 ? <div style={{marginRight:'5px'}}>NOT STARTED</div> : (row.ImplementationStatus == 1 ? <div style={{marginRight:'20px'}}>UNDERWAY</div> : (row.ImplementationStatus == 2 ? "IMPLEMENTED" : ""))}</div>
  
    <div className="align-middle text-center" style={{display: 'inline-block',paddingLeft:'0px'}}>
      <Input style={{ width: '167px',fontSize:'15px', height: '30px',backgroundColor:this.state.isManager === true || this.state.isAdmin===true ?'#FFFFFF':'#DCDCDC'}}
        type="date"
        readOnly={this.state.isManager === true || this.state.isAdmin === true ? false : true}
        placeholder="Enter Done Date"
        value={row.DoneDateVendorDisplay == null ? "2020-01-01" : row.DoneDateVendorDisplay}
        min="2020-01-01"
        max={currentDate}
      /></div>
      </div>
  ),
  center: true,
  width: 'auto',
},
EN

回答 1

Stack Overflow用户

发布于 2021-04-24 17:30:48

列API的选择器属性可以是字符串或函数。在下面的示例中,我将"firstName“和"lastName”组合在一起以生成"name“列

代码语言:javascript
复制
<DataTable
  columns={[
    {
      name: 'Name',
      selector: row => `${ row.firstName } ${ row.lastName }`
    },
    {
      name: 'Business Number',
      selector: 'businessNumber'
    },
    {
      name: 'Type',
      selector: 'type'
    }
  ]}
/>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65679394

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档