在PrimeNG中 - 有没有办法只允许一次扩展一行?
<p-dataTable [value]="cars" expandableRows="true">
<p-column expander="true" styleClass="col-icon"></p-column>
<p-column field="vin" header="Vin"></p-column>
<ng-template let-car pTemplate="rowexpansion">
...
</p-dataTable>
答案 0 :(得分:3)
只需尝试在<p-dataTable [value]="cars" rowExpandMode="single" expandableRows="true">
以下使用
添加rowExpandMode =“ single”一次可以打开一行。
答案 1 :(得分:0)
我可以告诉你如何解决它并希望它对你有用。
$(function(){
// check if there is a hash in the url
if ( window.location.hash != '' )
{
// remove any accordion panels that are showing (they have a class of 'in')
$('.collapse').removeClass('in');
// show the panel based on the hash now:
$(window.location.hash + '.collapse').collapse('show');
}
});
It is not the actual solution for this issue but you will get Idea how to
solve this. Also I am using javascript in the code. You can convert it into
angular way.
&#13;
<p-dataTable expandableRows="true"
(onRowExpand) = "onRowExpand($event)">
&#13;
onRowExpand(data : any) {
var d = document.getElementsByClassName('fa fa-fw ui-c ui-row-toggler fa-chevron-circle-down');
if (d.length > 0) {
for (var i = 0; i < d.length; i++) {
this.renderer.setElementStyle(d[i].parentElement.parentElement.parentElement.nextElementSibling,'display','none')
}
}
}
答案 2 :(得分:0)
当我将PrimeNG Grid升级为TurboTable版本时,问题解决了.. 它是自PrimeNG 5以来的新功能。 而不是使用
答案 3 :(得分:0)
PrimeNG 7.1.1:将rowExpandMode
属性设置为'single'即可。
<p-table #dt [columns]="cols" [value]="tableData" [rows]="pageOptions.perPage" [totalRecords]="totalRecords"[rowsPerPageOptions]="rowsPerPageOptions" [responsive]="true" rowExpandMode="single">