我们要求带有复选框和可扩展子节点的父元素需要具有单选按钮,因为树表仅支持复选框,我们为所需的复选框和单选按钮注入了动态HTML,问题是每当我们展开时或折叠子节点,所有单选按钮和复选框的选择都将被清除,我们在数组中具有选定项的列表,因此可以循环浏览,但是即使我们试图在nodeexpand事件中循环浏览列表也是如此选择已被清除,即使在节点展开或折叠之后,也请帮助我获得如何保持复选框和单选按钮绑定到innerHTML属性的状态的解决方案
<p-treeTable [value]="gridData" [columns]="scrollableColumns" [frozenColumns]="frozenCols" [scrollable]="true" frozenWidth="150px">
<ng-template pTemplate="colgroup" let-columns>
<colgroup>
<col *ngFor="let col of columns" style="width:250px;">
</colgroup>
</ng-template>
<ng-template pTemplate="header" let-columns>
<tr>
<th *ngFor="let col of columns;let i =index" style="height:47px !important">
<div *ngIf="col.field.toUpperCase() == 'SNO'" [innerHTML]="col.header | sanitizeHtml: 'html'" style="width:100px !important">
</div>
<div *ngIf="col.field.toUpperCase() != 'SNO'">
{{col.header}}
</div>
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowData="rowData" let-columns="columns">
<tr>
<td *ngFor="let col of columns; let i = index">
<div *ngIf="col.field.toUpperCase() == 'CURRENTDNBCOMPANYNAME'" (click)="showDialog()">
<a class="cusror">{{rowData[col.field]}}</a>
</div>
<div *ngIf="col.field.toUpperCase() != 'CURRENTDNBCOMPANYNAME'">
{{rowData[col.field]}}
</div>
</td>
</tr>
</ng-template>
<ng-template pTemplate="frozenbody" let-rowNode let-rowData="rowData">
<tr style="width:100px !important">
<td style="display:-webkit-inline-box;width:100% !important;">
<p-treeTableToggler class="{{rowData.class}}" [rowNode]="rowNode"></p-treeTableToggler>
<div [innerHTML]="rowData.Sno | sanitizeHtml: 'html'"></div>
</td>
</tr>
</ng-template>
</p-treeTable>
IN打字稿
this.gridData = [ { 数据:{类:“ abc”,Sno:”,RecommendedSource:“ DMS”,CityofRecommendedDNB:“ Redmond”,RecommendedDnB:“ Core American Security”,CurrentDNBCompanyName:“ ACADEMIE DE PARIS”,LegalEntityCompanyName:“ Microsoft Corp.”, CID:“ ebf1bd3b-37cb-4fdc-a463-fad6b8bb5d68”,DNBID:“ 392085739”,地址:“ France”,城市:“ 94 AVENUE GAMBETTA”, 扩展:正确, 儿童:[ { 数据:{Sno:``,RecommendationSource:'DMS-City:PARIS',CityofRecommendedDNB:'Jarvis',RecommendationDnB:'Core American Security',CurrentDNBCompanyName:'Académiede Paris',LegalEntityCompanyName:'Microsoft Corp.',CID: 'ebf1bd3b-37cb-4fdc-a463-fad6b8bb5d68',DNBID:'392085733',地址:'France',城市:'94 avenue GAMBETTA'}, }, { 数据:{Sno:``,RecommendationSource:'Jarvis',CityofRecommendedDNB:'Bellevue',RecommendationDnB:'Core American Security',CurrentDNBCompanyName:'Microsoft',LegalEntityCompanyName:'Microsoft Corp.',CID:'ebf1bd3b-37cb-4fdc -a463-fad6b8bb5d68”,DNBID:“ 234423423”,地址:“ U.S”,城市:“ GAMBETTA”}, 儿童:[ { 数据:{Sno:``,RecommendationSource:'DMS',CityofRecommendedDNB:'Seattle',RecommendationDnB:'Core American Security',CurrentDNBCompanyName:'Académiede Paris',LegalEntityCompanyName:'Microsoft Corp.',CID:'ebf1bd3b-37cb -4fdc-a463-fad6b8bb5d68”,DNBID:“ 4234234234”,地址:“ france”,城市:“ japan”}, }, { 数据:{Sno:``,RecommendationSource:'DMS',CityofRecommendedDNB:'Everret',RecommendationDnB:'ACADEMIE DE PARIS',CurrentDNBCompanyName:'Core American Security',LegalEntityCompanyName:'94 avenue',CID:'ebf1bd3b-37cb- 4fdc-a463-fad6b8bb5d68”,DNBID:“ 353534”,地址:“ japan”,城市:“ austin”}, } ] } ] }, { 数据:{类:“ abc”,Sno:“,RecommendmentSource:'DMS',CityofRecommendedDNB:'Redmond',RecommendedDnB:'Core American Security',CurrentDNBCompanyName:'Microsoft',LegalEntityCompanyName:'Microsoft Corp。',CID: '211fc80e-6d4b-4605-998b-b75945ff22f1',DNBID:'650558641',地址:'Chalfont',城市:'Pittsburgh'}, 扩展:正确, 儿童:[ { 数据:{Sno:``,RecommendationSource:'DMS',CityofRecommendedDNB:'Bellevue',RecommendationDnB:'Core American Security',CurrentDNBCompanyName:'Microsoft',LegalEntityCompanyName:'Microsoft Corp.',CID:'211fc80e-6d4b-4605 -998b-b75945ff22f1”,DNBID:“ 456783”,地址:“ Jarvis”,城市:“ My data health”}, 儿童:[ { 数据:{Sno:``,RecommendationSource:'DMS',CityofRecommendedDNB:'BELLEAVUE',RecommendationDnB:'Core American SECURITY',CurrentDNBCompanyName:'Microsoft',LegalEntityCompanyName:'Microsoft Corp.',CID:'211fc80e-6d4b-4605 -998b-b75945ff22f1”,DNBID:“ 45678356”,地址:“ Chalfont”,城市:“ Pittsburgh”}, }, { 数据:{Sno:``,RecommendationSource:'Jarvis',CityofRecommendedDNB:'Everret',RecommendationDnB:'Core American Security',CurrentDNBCompanyName:'Microsoft',LegalEntityCompanyName:'Microsoft Corp.',CID:'211fc80e-6d4b-4605 -998b-b75945ff22f1”,DNBID:“ 45678356”,地址:“匹兹堡”,城市:“ Chalfont”}, } ] } ] } ];