【问题标题】:add click event to ngx-datatable cell body将点击事件添加到 ngx-datatable 单元格主体
【发布时间】:2019-04-26 17:49:11
【问题描述】:

我想在 ngx-datatable 单元格主体的点击事件中调用一个函数。这是我现在的代码。

<ngx-datatable-column name="User Name" prop="userName">
    <ng-template ngx-datatable-cell-template let-rowIndex="rowIndex" let-value="value" let-row="row">
       <span *ngIf="!editable" (click)="editable = true;"> Some Text </span>
       <input type="text" *ngIf="editable"/>
    </ng-template>
</ngx-datatable-column>

我想将跨度点击事件中的内容移动到单元格主体点击事件中。我在尝试移动时遇到了一些问题,

  1. ng-template (click) 事件不起作用,
  2. 然后我尝试在 ng-template 中添加一个 div,但它只覆盖 span 区域。女巫是指没有覆盖整个细胞体的div。 (不允许更改单元格的默认样式)

【问题讨论】:

    标签: javascript angular6 ngx-datatable


    【解决方案1】:

    你能试试这个吗

    <ngx-datatable-column name="User Name" prop="userName">
        <ng-template ngx-datatable-cell-template let-rowIndex="rowIndex" let-value="value" let-row="row">
           <span *ngIf="!editable" (dblclick)="editable = true;"> Some Text </span>
           <input type="text" autofocus *ngIf="editable"/>
        </ng-template>
    </ngx-datatable-column>
    

    【讨论】:

    • 点击事件还在span中吧..? :) .. 感谢@aneri-vala 的帮助。但这不是我想要的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-25
    • 1970-01-01
    • 1970-01-01
    • 2013-02-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多