树形表,带有可排序表行(角度为5)

时间:2019-06-03 13:30:27

标签: angular html-table treeview angular5 ngx-bootstrap

  1. 我使用的是角度5,我想用可排序的表行来实现树表,但是排序行在下面的代码中不起作用。

    <table class="table table-bordered tabledesign">
        <thead>
            <tr>
                <th></th>
                <th>Sr #</span></th>
                <th>Name</th>
                <th>Is Active</th>
                <th>Action</th>
            </tr>
        </thead>
        <tbody>
            <ng-container *ngTemplateOutlet="treeViewTemplate; context:{ $implicit: menusList }">
            </ng-container>
        </tbody>
    </table>
    
    <bs-sortable [(ngModel)]="menusList" itemClass="sortable-item" itemActiveClass="sortable-item-active"
        placeholderItem="Drag here" placeholderClass="placeholderStyle" wrapperClass="sortable-wrapper"
        (ngModelChange)="participantSortingChange($event)" [itemTemplate]="treeViewTemplate">
    </bs-sortable>
    
    <ng-template #treeViewTemplate let-menusList>
        <ng-container *ngFor="let parameter of menusList">
            <tr [ngStyle]="{'background-color': parameter.color ? parameter.color : '' }">
                <td class="text-left">
                    <a *ngIf="parameter.child_menus?.length > 0" (click)="parameter.expand = !parameter.expand">
                        <i class="fa plus-icon" [ngClass]="parameter.expand ? 'fa-minus-square-o' : 'fa-plus-square-o'"></i>
                    </a>
                    <i *ngIf="parameter.child_menus?.length <= 0" class="fa fa-circle"
                        style="font-size: 10px; padding-right: 3px;color: #f68c1f;"></i>
                </td>
                <td>{{parameter.sr_no}}</td>
                <td class="text-left">{{parameter.name}}</td>
                <td class="text-left text-transform">{{parameter.is_active}}</td>
                <td class="text-center">
                    <a class="iconbtn btn-type1" data-title="View" tooltip="Add Sub Menu"
                        (click)="showSubMenuModal(parameter)">
                        <i class="fa fa-plus"></i>
                    </a>
                    <a class="iconbtn btn-type1" data-title="Edit" tooltip="Edit" (click)="showEditMenuModal(parameter)">
                        <i class="fa fa-pencil"></i>
                    </a>
                    <a class="iconbtn btn-type1" data-title="Delete" tooltip="Delete" (click)="showDeleteDialog(parameter)">
                        <i class="icon-trash"></i>
                    </a>
                </td>
            </tr>
            <ng-container *ngIf="parameter.expand && parameter.child_menus?.length > 0" class="pl-4">
                <ng-container *ngTemplateOutlet="treeViewTemplate; context:{ $implicit: parameter.child_menus }">
                </ng-container>
            </ng-container>
        </ng-container>
    </ng-template>
    
  

使用 bs-sortable ,我无法移动任何表行,因此如何实现可排序的表行

0 个答案:

没有答案