仅在md-data-table中选择一行

时间:2016-12-16 11:54:30

标签: javascript angularjs datatable datatables

我有这段代码

<md-card>
  <md-content layout="column" flex>
    <md-table-container>
      <table md-table md-row-select="true" multiple="true" ng-model="selected">
        <thead md-head md-order="query.order">
          <tr md-row>
            <th md-column ng-repeat="column in autocolumn" md-order-by="{{column.name}}">
              <span>{{column.display}}</span>
            </th>
          </tr>
        </thead>
        <tbody md-body>
          <tr md-row md-select="row" md-auto-select="true" ng-repeat="cliente in clientes | orderBy: query.order | limitTo: query.limit : (query.page -1) * query.limit">
            <td md-cell>{{cliente.1}}</td>
            <td md-cell><a ng-click="send(this);">{{cliente.2}}</a></td>
            <td md-cell nowrap>{{cliente.3}}</td>
            <td md-cell nowrap>{{cliente.4}}</td>
            <td md-cell>{{cliente.5}}</td>
            <td md-cell>{{cliente.6}}</td>
          </tr>
        </tbody>
      </table>
    </md-table-container>
    <md-table-pagination md-limit="query.limit" md-limit-options="limitOptions" md-page="query.page" md-total="{{datatable.count}}" md-page-select="options.pageSelect"></md-table-pagination>
  </md-content>
</md-card>

我尝试只选择一行或两行,但是当我单击一行时更改所有行以进行检查。

1 个答案:

答案 0 :(得分:1)

通过cliente更改行

<tbody md-body>
          <tr md-row md-select="cliente" md-auto-select="true" ng-repeat="cliente in clientes | orderBy: query.order | limitTo: query.limit : (query.page -1) * query.limit">
            <td md-cell>{{cliente.1}}</td>
            <td md-cell><a ng-click="send(this);">{{cliente.2}}</a></td>
            <td md-cell nowrap>{{cliente.3}}</td>
            <td md-cell nowrap>{{cliente.4}}</td>
            <td md-cell>{{cliente.5}}</td>
            <td md-cell>{{cliente.6}}</td>
          </tr>
        </tbody>