返回顶部
首页 > 资讯 > 前端开发 > JavaScript >Angular4中的checkbox 全选按钮启用禁用
  • 258
分享到

Angular4中的checkbox 全选按钮启用禁用

摘要

这客户比较特殊,啥都得选中行能选中checkbox,并且未选中时按钮需要禁用。 可以理解 代码比较简单,table代码: <div class="modal-header"&

Angular4_table中的checkbox 全选,按钮启用禁用_SAP

这客户比较特殊,啥都得选中行能选中checkbox,并且未选中时按钮需要禁用。 可以理解

代码比较简单,table代码:

<div class="modal-header">
          <p class="modal-title">LoGout Warnning</p>
        </div>
        <div class="modal-body">
                <p>Your have working order(s). if you logout the order(s) will be returned to the Pick Queue and all unconfirmed handling units will remove. Do you want to continue logout"table">
                <thead>
                  <tr>
                    <th>
                        <input type="checkbox" name="checkedAll" [checked]="isAllChecked()" (change)="checkAll($event)">
                    </th>
                    <th>Phase Code</th>
                    <th>Delivery</th>
                    <th>Product</th>
                  </tr>
                </thead>
                <tbody>
                  <tr *ngFor="let task of this.releaseTasks.releaseTaskDetails index as i;"(click)="onModalSelectedRows(task)"
>
                    <td>
                        <input type="checkbox" [(ngModel)]="task.isChecked" name="checkedTask{{i}}" #checkedTask="ngModel"/>
                    </td>
                    <td>
                        {{task.phaseCode}}
                    </td>
                    <td>
                        {{task.saP_DeliveryOrder_ID}}
                    </td>
                    <td>
                        {{task.saP_ProductOrder_ID|removeLeadingZeros}}
                    </td>
                  </tr>
                </tbody>
              </table>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" (click)="c('Yes')" [disabled]="!canRelease">Release and logout</button>
          <button type="button" class="btn btn-primary" (click)="c('No')">Logout only</button>
        </div>
​​checkAll(ev: any) {​​
 ​​this.releaseTasks.releaseTaskDetails.forEach((x:any) => x.isChecked = ev.target.checked)​​
 ​​ }​​
 ​​isAllChecked() {​​
 ​​if(this.releaseTasks.releaseTaskDetails.length > 0​​
 ​​return this.canRelease = this.releaseTasks.releaseTaskDetails.every((_:any) => _.isChecked);​​
 ​​ }​​
 ​​return false;​​
 ​​ }​​
 ​​​​​​
    onModalSelectedRows(task
     : 
     any) {
    
    task.
     isChecked 
     = 
     !
     task.
     isChecked;
    
    let 
     len 
     = 
     0;
    
    this.
     releaseTasks.
     releaseTaskDetails.
     forEach((item
     : 
     any) 
     =>
    if(
     item.
     isChecked) {
    
    len 
     ++;
    
    
      }
    
    
      });
    
    if(
     len 
     === 
     0) {
    
    this.
     canRelease 
     = 
     false;
    
    else{
    
    this.
     canRelease 
     = 
     true;
    
    
      }
    
    
      }
    ​​​​后台的viewmodel代码​​

Controller 代码

var activityQuery = from op in _context.OperatorActivities
                                where op.Operator_ID == userName && !op.IsComplete && !op.IsReleased && !op.IsException 
                                select op;
            
            ReleaseTask relesaseTask = new ReleaseTask();

            if(activityQuery.Any()){
                foreach (var activity in activityQuery)
                {
                    ReleaseTaskViewModel taskDetail = new ReleaseTaskViewModel();
                    taskDetail.SAP_DeliveryOrder_ID = getOrderById(activity.DeliveryOrder_ID);
                    taskDetail.SAP_ProductOrder_ID = getProductOrderById(activity.ProductionOrder_ID);
                    taskDetail.PhaseCode = activity.ActivityCode;
                    taskDetail.isChecked = true;
                    taskDetail.OperatorActivityId = activity.OperatorActivity_ID;
                    taskDetail.DeliveryOrder_ID = activity.DeliveryOrder_ID;
                    taskDetail.ProductionOrder_ID = activity.ProductionOrder_ID;
                    taskDetail.Operator_ID = activity.Operator_ID;
                    taskDetail.OrderId = activity.ActivityCode == "MAKE" ? activity.ProductionOrder_ID : activity.DeliveryOrder_ID;
                    taskDetail.isPersistent = isPersistent(activity.ProductionOrder_ID);
                    if(!taskDetail.isPersistent) {
                        relesaseTask.ReleaseTaskDetails.Add(taskDetail);
                    }
                }
            }
            return(Ok(new { success = true, data = relesaseTask}));

到此这篇关于angular4中的checkbox 全选按钮启用禁用的文章就介绍到这了,更多相关Angularjs实现checkbox 全选内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: Angular4中的checkbox 全选按钮启用禁用

本文链接: https://lsjlt.com/news/198558.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作