question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Drag and drop reordering of columns should allow for dropping only and not swapping

See original GitHub issue

Currently dragging and dropping columns swaps the columns, that is the dragged column and the column dragged into, with each other. Instead, there should be a way to allow column dragging so that it only drops it into position and shifts the other columns to the right.

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior Currently when you drag a column to the position of another column, it swaps the columns, so if you drag a column in a 10 column grid, that is at the very right of the grid, to a position in the beginning, it will swap the columns instead of simply shifting the first column to the right and placing the dragged column in its place.

Expected behavior See above.

Reproduction of the problem See any of the demo apps.

What is the motivation / use case for changing the behavior? Usually column drag and drop does not swap columns but instead shifts columns.

Please tell us about your environment: All

  • Table version: 0.8.x Latest

  • Angular version: 2.0.x 4.x

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X all

  • Language: [all | TypeScript X.X | ES6/7 | ES5] TypeScript

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:22 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
bergermanuelcommented, Jan 26, 2018

We’re currently working on a project where we needs this functionality of reordering columns and not swapping them. We decided to implement it by ourselves and created a PR. We hope it will be merged.

3reactions
CwkMastercommented, Feb 22, 2018

Hi, everyone! I had that same problem. I did this(Angular5, ngx-datatable 11.1.7):

In html:

   <ngx-datatable  [columns]='columns' 
    (reorder)="reorderColumn($event)" ">  

In TS:

reorderColumn(event) {
        let i = 0;
        let newOrderedColumns = [];
        for (let col of this.columns) {
            if (event.newValue == i) {
                newOrderedColumns.push(event.column);
                newOrderedColumns.push(col);
            } else if (event.prevValue == i) {

            } else {
                newOrderedColumns.push(col);
            }
            ++i;
        }
        this.columns = newOrderedColumns;
        this.saveColumnOrder(); //save in Local Storige
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Excel: How to move (swap) columns by dragging and other ways
Press and hold down the Shift key and drag the column to a new location. That's it! Release the mouse button, then leave...
Read more >
Swapping Content of Cells/Columns/Rows - Apple Community
When using Pages '08, dragging and dropping cells, onto other cells in a table, resulted in the contents being swapped.
Read more >
drag and drop / reordering in Kendo UI for jQuery - Telerik
I need a way of changing the order of rows in a grid and updating the datasource accordingly. I could do this by...
Read more >
Drag and Drop support for column reordering in DataGrid control
MoveColumn performs the intelligent column reordering where dragged column will be positioned before the dropped column if the dragged column ...
Read more >
Let's Build DnD Column Reordering in an HTML Table w
Now, we have the index of the column we were dragging and the index of the column we want to drop on (replace)....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found