胡子哥哥
2023-05-11 14:47:04
我試圖將一行的列拖到另一行,但它不能拖放到另一行的列數組。我有以下類型的數組(示例數據數組)。[ { // row key: value, cols: [{ key: value }] // cols array }, //n numers of row]我的代碼。<table id="id"> <tbody sortablejs ngDefaultControl [(ngModel)]="Array"> <tr *ngFor="let item of Array; let i = index"> <td class="myRowClass sort-disabled"> <!-- index logic --> </td> <td class="myRowClass sort-disabled"> <!--logic --> </td> <td sortablejs> <div *ngFor="let cell of item.cols" class="divSize"> <!-- column logic --> </div> </td> </tr> </tbody></table>
1 回答

揚帆大魚
TA貢獻1799條經驗 獲得超9個贊
通過使用[sortablejsOptions]="options"我實現了我的功能。
<table id="id">
<tbody [sortablejs]="Array" [sortablejsOptions]="Array">
<tr *ngFor="let item of Array">
<td class="myRowClass sort-disabled">
<!-- index logic -->
</td>
<td>
<!--row logic -->
</td>
<td [sortablejs]="item.cols" [sortablejsOptions]="options">
<div *ngFor="let cell of item.cols; let j = index">
<!--column logic -->
</div>
</td>
</tr>
</tbody>
</table>
.ts 文件組名中的選項必須相同。
options: Options = {
group: { name: "test" }
}
添加回答
舉報
0/150
提交
取消