简体   繁体   English

角度6中每个剑道网格行的弹出窗口

[英]Popup for each kendo-grid row in angular 6

I working with kendo grid and Angular 6. each row has action button in kendo column which is (preview) for each row. 我使用kendo网格和Angular6。每一行在kendo列中都有动作按钮,每一行都是(预览)。 By clicking it, it previews in a popup, only this row information. 通过单击它,它将仅在弹出窗口中预览此行信息。 I used this tutorial for making the popup 我使用了本教程制作弹出窗口

https://www.telerik.com/kendo-angular-ui/components/popup/ https://www.telerik.com/kendo-angular-ui/components/popup/

and it worked, unless, if I press "show" button for any row, all show buttons open the popups and same for close button, close all the popups. 并且它的工作原理是,除非我在任何行上按“显示”按钮,否则所有显示按钮都将打开弹出窗口,而对于关闭按钮相同,请关闭所有弹出窗口。

    <kendo-grid-column field="tests" title="Actions" width="120" [locked]="true">
      <ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">            
        <div>
          <div class="example-config">
            <button #anchor (click)="onToggle()" class="btn" class="btn btn-primary btn-lg gradient">{{toggleText}}</button>
          </div>
          <kendo-popup [anchor]="anchor" *ngIf="show" [animate]="animate">
<!--(anchorViewportLeave)="show = false"-->
            <div class='content'>
                   <--!content here-->
             </div>

You are currently tracking the active state for all the popups in one single variable called show . 当前,您正在一个名为show单个变量中跟踪所有弹出窗口的活动状态。 Which causes all popups to show/hide at the same time. 这将导致所有弹出窗口同时显示/隐藏。

But you need to track the active state per row/dataItem. 但是您需要跟踪每个行/数据项的活动状态。

Track per dataItem 跟踪每个数据项

One option would be to track the active state of the rows popup in the dataItem itself. 一种选择是跟踪dataItem本身中行弹出窗口的活动状态。

<button #anchor (click)="dataItem.show = !dataItem.show" class="btn btn-primary">Preview</button>

<kendo-popup [anchor]="anchor" *ngIf="dataItem.show" [animate]="animate">
     <-- content here -->
</kendo-popup>

Track per rowIndex 每行跟踪

Alternatively one could track the active state in a global variable based on the rowIndex . 或者,可以基于rowIndex在全局变量中跟踪活动状态。 Which is provided by the kendoGridCellTemplate . kendoGridCellTemplate提供。

<button #anchor (click)="show[rowIndex] = !show[rowIndex]" class="btn btn-primary">Preview</button>

<kendo-popup [anchor]="anchor" *ngIf="show[rowIndex]" [animate]="animate">
     <-- content here -->
</kendo-popup>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM