【问题标题】:Select only a row in md-data-table只选择 md-data-table 中的一行
【发布时间】:2017-05-02 05:12:06
【问题描述】:

我有这个代码

<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>

我尝试只选择一两行。但是当我点击一行时,所有行都会被检查。

【问题讨论】:

    标签: javascript angularjs datatable datatables


    【解决方案1】:

    md-select 的值更改为迭代别名。

    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-11
      • 1970-01-01
      • 2019-07-10
      • 1970-01-01
      • 2021-07-14
      • 2021-05-08
      相关资源
      最近更新 更多