如何从表的开头colspan tr表

时间:2017-03-24 10:22:40

标签: javascript html css angularjs

我想从第二列开始colspan我的意思是名字: enter image description here

enter image description here

<table width="100%">
  <thead style="background-color: lightgray;">
    <tr>
      <td style="width: 30px;"></td>
       <td><p>Name</p></td>
    <td><p>ID</p></td>
    <td><p>GPS date</p></td>
    <td><p>Adresse</p></td>
    <td><p>Company</p></td>
    </tr>  
  </thead>
  <tbody>
    <tr ng-repeat-start="device in MyDeviceObject">
      <td>
        <button ng-if="device.expanded" ng-click="device.expanded = false">-</button>
        <button ng-if="!device.expanded" ng-click="device.expanded = true">+</button>
      </td>
      <td><p>{{device.name}}</p></td>
      <td><p>{{device.uniqueid}}</p></td>
      <td><p>{{device.devicetime}}</p></td>
      <td><p>{{device.adress}}</p></td>
      <td><p>{{device.company}}</p></td>
    </tr>
    <tr  ng-if="device.expanded" ng-repeat-end="">
      <td  colspan="6">gfhgfjhfjtjrtkjy</td>
    </tr>
  </tbody>

请有人告诉我如何从名字中删除?

2 个答案:

答案 0 :(得分:0)

您似乎只需要在行中添加<td>即可。你有:

<tr ng-if="device.expanded" ng-repeat-end="">
    <td colspan="6">gfhgfjhfjtjrtkjy</td>
</tr>

将其更改为:

<tr ng-if="device.expanded" ng-repeat-end="">
    <td style="width: 30px;"></td>
    <td colspan="5">gfhgfjhfjtjrtkjy</td>
</tr>

这应该在<td>图标下方添加plus/minus。此外,如果您不打算将其显示为列(我认为这是您的意图),您可以设置此<td>的样式。

希望有所帮助。

答案 1 :(得分:0)

<table width="100%">
  <thead style="background-color: lightgray;">
    <tr>
      <td style="width: 30px;"></td>
       <td><p>Name</p></td>
    <td><p>ID</p></td>
    <td><p>GPS date</p></td>
    <td><p>Adresse</p></td>
    <td><p>Company</p></td>
    </tr>  
  </thead>
  <tbody>
    <tr ng-repeat-start="device in MyDeviceObject">
      <td>
        <button ng-if="device.expanded" ng-click="device.expanded = false">-</button>
        <button ng-if="!device.expanded" ng-click="device.expanded = true">+</button>
      </td>
      <td><p>{{device.name}}</p></td>
      <td><p>{{device.uniqueid}}</p></td>
      <td><p>{{device.devicetime}}</p></td>
      <td><p>{{device.adress}}</p></td>
      <td><p>{{device.company}}</p></td>
    </tr>
    <tr  ng-if="device.expanded" ng-repeat-end="">
      <td  colspan="6">gfhgfjhfjtjrtkjy</td>
    </tr>
    <tr ng-repeat-start="device in MyDeviceObject">
      <td>
        <button ng-if="device.expanded" ng-click="device.expanded = false">-</button>
        <button ng-if="!device.expanded" ng-click="device.expanded = true">+</button>
      </td>
      <td colspan="2" align="center"><p>{{device.name}}</p></td>

      <td><p>{{device.devicetime}}</p></td>
      <td><p>{{device.adress}}</p></td>
      <td><p>{{device.company}}</p></td>
    </tr>