element-ui-el-table-draggable icon indicating copy to clipboard operation
element-ui-el-table-draggable copied to clipboard

Problem using table with "expanded" columns

Open jonathanpmartins opened this issue 4 years ago • 1 comments

There is a problem using sortable when the table has "expanded" columns.

Inside the template of my project, I use a column of type expand.

<el-table-column
  type="expand"
>
  <template slot-scope="props">
    {{ props.row.comment }}
  </template>
</el-table-column>

When the row is expanded, or if I use default-expand-all prop on the table, the onEnd function will return wrong indexes inside SortableElTable component file:

sortable.create(table, {
  handle: this.handle,
  animation: this.animate,
  onEnd: ({ newIndex, oldIndex }) => {
    // there two parameter can return wrong values when using columns of type "expand"
  }
});

The first thing that came into my mind was to close all expanded rows before beginning the drag. If I do it manually it works as it should. But when a row is expanded (let say) on index 5, everything below will have a wrong index. Would be nice to have an event that will dispatch before drag init like ondragstart, this way I can close everything before the drop.

Another solution would be to change the onEnd method to predict that behavior. I'm looking into that...

jonathanpmartins avatar Sep 30 '20 20:09 jonathanpmartins

Just created a pull request for the onStart event. https://github.com/WakuwakuP/element-ui-el-table-draggable/pull/27

jonathanpmartins avatar Sep 30 '20 20:09 jonathanpmartins