angular - 我在 ngx-datatable 的每个标题单元格中都有一个自定义下拉组件

标签 angular typescript angular2-template ngx-datatable

我在 ngx-datatable 的每个标题单元格中都有自定义下拉组件。但是当我点击下拉菜单时,它会进入 ngx-datatable 主体。我该如何解决这个问题请帮助我。

我使用的是 angular 4.0 和 typescript 2.4。

屏幕截图: enter image description here

enter image description here

这是我的代码:

 <div>
      <ngx-datatable style="height:450px;"
        class='material'
        [rows]='activeTabData | filtermanual:propKey:propValue | orderBy : {property: column, direction: direction}'
        [columnMode]="'force'"
        [headerHeight]="height"
        [rowHeight]="getRowHeight"
        [scrollbarV]="true"
        [scrollbarH]="true"
        [loadingIndicator]="loadingIndicator"
        [rowClass]="getRowClass"
        (page)="onPage($event)">
      <div>
        <ngx-datatable-column 
          [width]="50"
          [frozenLeft]="true">
            <ng-template let-row="row" let-value="value" ngx-datatable-cell-template >
              <input type="checkbox" 
              (ngModelChange)="checkButtonState($event, row)"
              [ngModel]="row.status"
              >
          </ng-template>
        </ngx-datatable-column>

        <ul>
          <li *ngFor="let col of tableKeys; let i=index; let last = last" >
        <ngx-datatable-column name={{col}} width="230" [resizeable]="true">
          <ng-template let-column="column" ngx-datatable-header-template >
              <div class="draggable" style="height:30px;width:160px;background:transparent;z-index:1000;position:relative;cursor:pointer;"></div>

                                    <ng2-multiselect 
                                      [options]="dropdowns[col]"
                                      [loading]="isLoading"
                                      [(ngModel)]="multiModels[col]"
                                      [texts]="{'defaultTitle':col}"
                                      (dropdownOpen)="dropdownOpen()"
                                      (dropdownClosed)="dropdownClosed(col)"
                                      >
                                    </ng2-multiselect>   
        </ng-template>

          <ng-template let-row="row" let-value="value" ngx-datatable-cell-template >
              <i [innerHTML]="row[col]"></i>
          </ng-template>
        </ngx-datatable-column>

          </li>
        </ul>
      </div>
      </ngx-datatable>
    </div>

最佳答案

对于 ngbDropdown 下拉列表,我通过添加 container="body" 属性解决了类似的问题,如下所示:

<div ngbDropdown class="d-inline-block" container="body">
....
.....
</div>

关于angular - 我在 ngx-datatable 的每个标题单元格中都有一个自定义下拉组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46130439/

相关文章:

google-maps - 如何将 Google Maps API 集成到 Angular 2 组件中

javascript - anchor 标记不起作用

angular - [ngClass] ="computeClass()"和 Angular 4 中的类 ="{{computeClass()}}"之间的区别

angular - 路由器 socket 工作不正常

angular - ngAfterViewInit() 和 ngAfterViewChecked() 有什么区别?

javascript - 首次加载组件时更改 mat-grid-list 中的列数

angular - 将所有带有哈希的 URL 重定向到没有哈希的 Angular 路由

typescript - DefinitelyTyped 是否适合新的 TypeScript 定义?

reactjs - redux-thunk:通过 store.dispatch() 调用操作时缺少属性 'type'

angular2-template - 角度2 : Why we use asterik with ngif and ngfor?