Skip to content

moveColumn service works incorrectly if user pins a column #2346

@MeMea66

Description

@MeMea66

go to http://ui-grid.info/docs/#/tutorial/401_AllFeatures
pin a column to the left (ie address.street)
try to move a column after its original position (like address.city)
the wrong column gets moved.

or move a column before its original position (like name)
and the column gets moved to the wrong position

I havent looked into this very deeply but I think it is because of how the number of columns hidden by scroll is calculated:

var renderedColumns = $scope.grid.renderContainers['body'].renderedColumns;

//This method will calculate the number of columns hidden in lift due to scroll
//renderContainer.prevColumnScrollIndex could also have been used but this is more accurate
var scrolledColumnCount = 0;
var columns = $scope.grid.columns;
for (var i = 0; i < columns.length; i++) {
  if (columns[i].colDef.visible && columns[i].colDef.name !== renderedColumns[0].colDef.name) {
    scrolledColumnCount++;
  }
  else {
    break;
  }
}

renderedColumns doesnt include the pinned columns but grid.columns does so all columns pinned are automatically considered "hidden columns"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions