SortableJS / ngx-sortablejs

Angular 2+ binding to SortableJS. Previously known as angular-sortablejs

Home Page:https://sortablejs.github.io/ngx-sortablejs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Drag and drop column to another row in table.

rajgohel opened this issue · comments

I am trying to drag column of a row to another row but it can't drop to another row's column array. I have following type of array ( sample data array ).

[
 { // row
   key: value,
   cols: [{ key: value }] // cols array
 },
//n numers of row
]

My code.

<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>

By using [sortablejsOptions]="options" i achieved my functionality.

<table>
 <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>

options in .ts file group name must be same.

options: Options = {
    group: { name: "test" }
}