首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >smart-table st-sort只排序一半

smart-table st-sort只排序一半
EN

Stack Overflow用户
提问于 2015-12-11 05:53:41
回答 1查看 324关注 0票数 0

我正在使用smart-table显示一个包含员工姓名、分机等的表。我的数据加载得很好,但是当我尝试使用st-sort进行排序时,它只对行的上半部分进行排序。总是一半,总是最高的。

下面是表格的html代码片段:

代码语言:javascript
复制
<div class="col8" ng-controller="employeeCtrl">
    <table st-table="employeesCollection" st-safe-src="employeesCollection" class="table table-striped">
        <thead>
            <tr>
                <th st-sort="firstName" st-skip-natural="true">First Name</th>
                <th st-sort="lastName" st-skip-natural="true">Last Name</th>
                <th st-sort="extension" st-skip-natural="true">Extension</th>
                <th st-sort="city" st-skip-natural="true">Store City</th>
                <th st-sort="number" st-skip-natural="true">Store Number</th>
            </tr>
            <tr>
                <td>
                    <input type="text" id="FirstName" size="10" ng-keyup="searchEmp()" /></td>
                <td>
                    <input type="text" id="LastName" size="10" ng-keyup="searchEmp()" /></td>
                <td>
                    <input type="text" id="Extension" size="10" ng-keyup="searchEmp()" /></td>
                <td>
                    <select id="store" onchange="searchEmp()">
                        <option value=''>Select City</option>
                        <% For Each city In cityList%>
                        <option value="<%=city%>"><%=city%></option>
                        <% Next%>
                    </select></td>
                <td>
                    <select id="storeNo" onchange="searchEmp()">
                        <option value=''>Select Store</option>
                        <% For Each store In storeList%>
                        <option value="<%=store%>"><%=store%></option>
                        <% Next%>
                    </select>
                </td>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="employee in employeesCollection">
                <td ng-repeat="col in employee track by $index">{{col}}</td>
            </tr>
        </tbody>
    </table>
</div>

有人有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2015-12-11 06:05:51

我注意到的一件事,可能是问题所在,您在st-table指令和st-safe-src指令中使用了相同的集合。如果您使用的是异步数据,则需要按照文档中的方式进行设置:

代码语言:javascript
复制
st-table="displayedCollection" st-safe-src="rowCollection"

在你的控制器中:

代码语言:javascript
复制
$scope.displayedCollection = [].concat($scope.rowCollection);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34212448

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档