gpt4 book ai didi

javascript - Angular5/PrimeNG - p-listbox - onDblClick - 事件问题

转载 作者:行者123 更新时间:2023-12-03 02:34:38 25 4
gpt4 key购买 nike

我尝试使用 p-listbox - onDblClick - 事件,但它没有返回选定的列表元素。

相反,事件对象只有 this 值,

{"originalEvent":{"isTrusted":true}}

HTML

block 引用

<!-- Selected Tables -->
<p-listbox [options]="selectedTables" (onDblClick)="tableListBoxSelectEvent($event)" [listStyle]="{'min-height':'100px','max-height':'100px'}">
<ng-template let-table pTemplate="item">
<div class="ui-helper-clearfix">
<span style="float:left;">{{table.tableLabel}}</span>
</div>
</ng-template>
</p-listbox>

typescript

// Table select event from the Selected tables list box
tableListBoxSelectEvent(event) {
console.log('this.choosenTable >> ' + JSON.stringify(event));
}

引用:https://www.primefaces.org/primeng/#/listbox

更新:-

我的“selectedTables”JSON 对象如下,

 dummy3 = [
{
"reportType": "COREP ALM",
"startDate": "31-12-2016",
"endDate": "30-03-2018",
"tableId": 369,
"tableCode": "C 69.00.w",
"tableLabel": "Prices for various lengths of funding. Significant currencies"
}, {
"reportType": "COREP ALM2",
"startDate": "30-06-2015",
"endDate": "30-03-2018",
"tableId": 372,
"tableCode": "C 71.00.a",
"tableLabel": "Concentration of counterbalancing capacity by issuer/counterparty. Total"
}];

最佳答案

这是一个可行的解决方案。查看打印正在单击的选定列表元素plunker:

注意:确保在双击后打开开发工具以查看元素的值。

如果您想打印该值,只需执行以下操作:

console.log('this.choosenTable >> ' + JSON.stringify(event.value));

工作解决方案: PLUNKER

<p-listbox [options]="selectedTables" (onDblClick)="tableListBoxSelectEvent($event)" [listStyle]="{'min-height':'100px','max-height':'100px'}">
<ng-template let-table pTemplate="item">
<div class="ui-helper-clearfix">
<span style="float:left;">{{table.tableLabel}}</span>
</div>
</ng-template>
</p-listbox>

关于javascript - Angular5/PrimeNG - p-listbox - onDblClick - 事件问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48587764/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com