【问题标题】:Make last row NON sortable使最后一行不可排序
【发布时间】:2016-09-04 13:42:47
【问题描述】:

我的 Angular 项目中有可排序的表行,但排序行还包含查询 UI 代码元素,现在我不想让最后一行不可排序。

HTML

<div ng:controller="controller">
    <table style="width:auto;" class="table table-bordered">
        <thead>
            <tr>
                <th>Index</th>
                <th>Count</th>
            </tr>
        </thead>
        <tbody ui:sortable ng:model="list">
            <tr ng:repeat="item in list" class="item" style="cursor: move;">
                <td>{{$index}}</td>
                <td>{{item}}</td>
            </tr>
            <tr>
                <td>Non Sortable</td>
                <td>Non Sortable</td>
            </tr>
        </tbody>{{list}}
        <hr>
</div>

控制器

var myapp = angular.module('myapp', ['ui']);

myapp.controller('controller', function ($scope) {
    $scope.list = ["one", "two", "thre", "four", "five", "six"];
});

angular.bootstrap(document, ['myapp']);

JsFiddle 在这里工作:http://jsfiddle.net/valor_/fc7oftkn/

那么如何使最后一行不可排序?如果您需要任何其他信息,请告诉我,我会提供。提前谢谢你

【问题讨论】:

    标签: javascript jquery angularjs jquery-ui


    【解决方案1】:

    只需将它们移至&lt;tfoot&gt;,如下所示。

    <table style="width:auto;" class="table table-bordered">
      <thead>
        <tr>
          <th>Index</th>
          <th>Count</th>
        </tr>
      </thead>
      <tbody ui:sortable ng:model="list">
        <tr ng:repeat="item in list" class="item" style="cursor: move;">
          <td>{{$index}}</td>
          <td>{{item}}</td>
        </tr>
    
      </tbody>{{list}}
      <tfoot>
        <tr>
          <td>Non Sortable</td>
          <td>Non Sortable</td>
        </tr>
      </tfoot>
    </table>
    

    【讨论】:

    • 大声笑:我在这里笑死我了。我怎么没想到xD Thx。一旦允许,我会接受你的答复
    • @Valor_ 哈哈 :) 谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-07
    • 2022-01-12
    • 2011-12-16
    • 1970-01-01
    • 1970-01-01
    • 2012-06-01
    • 2019-04-07
    相关资源
    最近更新 更多