【问题标题】:Organize list in a table based on which button appears根据出现的按钮在表格中组织列表
【发布时间】:2023-03-15 07:45:02
【问题描述】:
<thead>
    <tr class="header-bg">
         <th>Action</th>
         <th>Name</th>
         <th>Email</th>
         <th>Vendor</th>
         <th>Position</th>
         <th>Phone Number</th>
         <th>Comment</th>
    </tr>
</thead>
<tbody ng-repeat="entry in vm.emailList | orderBy: Name">
    <tr>
        <td>
            <a class="btn btn-danger relative fa fa-trash-o" ng-click="vm.deleteUser(entry)"> Delete</a>
            <a class="btn btn-success relative fa fa-users" ng-show="!entry.CAUserID" ng-click="vm.approveUser(entry)"> Approve</a>
            <a class="btn btn-info relative fa fa-pencil" ng-show="entry.CAUserID" ng-click="vm.editUser(entry)"> Edit</a>
            </td>
            <td>{{entry.UserName}}</td>
            <td>{{entry.UserID}}</td>
            <td>{{entry.CompanyName}}</td>
            <td>{{vm.convertPositionName(entry)}}</td>
            <td>{{entry.PhoneNumber}}</td>
            <td>{{entry.Comment}}</td>
        </tr>
</tbody>

根据是否存在属性 CAUserID,我现在会显示批准或编辑按钮。

现在我的表是根据用户名组织的。但我希望首先根据是否出现批准或编辑按钮进行组织,然后按名称进行组织。

示例: 如果有两个用户有一个批准按钮并且他们的名字是 John 和 Sam。然后有三个用户有一个编辑按钮,他们的名字是 Jen、Dan 和 Tim。

此列表的组织方式如下: 约翰 山姆 担 仁 蒂姆

【问题讨论】:

    标签: javascript html angularjs


    【解决方案1】:

    按钮可见性的条件非常简单,您可以使用它代替实际的按钮可见性 - 尝试将 CAUserID 字段添加到您的 orderBy 子句。

    【讨论】:

      【解决方案2】:

      你试过了吗:

      <tbody ng-repeat="entry in vm.emailList | orderBy: ['CAUserID', 'Name']">
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-02-28
        • 1970-01-01
        • 2013-11-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-25
        相关资源
        最近更新 更多