Skip to content

Table Cols not sortable ... fix? #173

@dirkdirk

Description

@dirkdirk

I have tables with many cols and the js as provided in the example only seems to work consistently on tables with 2 cols.

I rewrote onDrop to the following that seems to be working consistently:

    onDrop: function ($item, container, _super) {
        var field;
        var newIndex = $item.index();

        if(newIndex != oldIndex) {
            $item.closest('table').find('tbody tr').each(function (i, row) {
                row = $(row);
                if(newIndex < oldIndex) {
                    row.children().eq(newIndex).before(row.children()[oldIndex]);
                } else if (newIndex > oldIndex) {
                    row.children().eq(newIndex).after(row.children()[oldIndex]);
                }
            })
        }
        _super($item, container);
    }

Comments?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions