简体   繁体   English

如何在反应表中调整整个列边框

[英]How to adjust whole column border in react-table

I'm trying to adjust style as the screenshot below 我正在尝试调整样式,如下图所示

What I expect to be: 我期望是:

我期望是

But what I got now is: 但是我现在得到的是:

我现在得到的

As you can see the border bottom of last column not apply to as expect. 如您所见,最后一列的边框底部未按预期适用。

I already try props which react-table provided but still can't figure out how to achieve it. 我已经尝试过提供反应表的道具,但仍然不知道如何实现。

Props list which apllied: 道具清单:

  1. styles 样式
  2. getProps getProps
  3. getTheadGroupTrProps getTheadGroupTrProps
  4. getTrProps getTrProps
  5. getTbodyProps getTbodyProps
  6. getTdProps getTdProps

All props that I applied, I used the condition to check if it the last record it will apply border-bottom style. 我应用了所有道具,我使用条件检查它是否将应用边框底样式的最后一条记录。

If anyone has any suggestion or any solutions.Help me please. 如果有人有任何建议或解决方案。请帮助我。

Thank you so much for your kindness. 非常感谢您的好意。

Assuming lastRowIndex contains the index of your last row, you can define this function 假设lastRowIndex包含最后一行的索引,则可以定义此函数

const styleRow = (state, rowInfo) => {
  if (!rowInfo) return
  return {
    style: {
      borderBottom: rowInfo.index === lastRowIndex? ˋ1px solid;ˋ : ˋˋ
    }
  }
}

and set it as geTrProps in your react-table. 并将其设置为您的反应表中的geTrProps。

<table class="table" id="table_Container">
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
      <tr>
        <td>Mary</td>
        <td>Moe</td>
        <td>mary@example.com</td>
      </tr>
      <tr>
        <td>July</td>
        <td>Dooley</td>
        <td>july@example.com</td>
      </tr>
    </tbody>
  </table>


       #table_Container tr th:last-child{ border-right: 1px solid red; border-left:1px solid red}
#table_Container tr td:last-child{ border-right: 1px solid red; border-left:1px solid red}
#table_Container tr:last-child td:last-child{border-bottom:1px solid red}
#table_Container tr td{border-top: 2px solid #dee2e6;}

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

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