4

I am implementing http://ui-grid.info/ in my application.

There is a feature of Column Moving, where Columns can be moved.

http://ui-grid.info/docs/#/tutorial/217_column_moving

DEMO

This is how i add columns :-

$scope.gridOptions.columnDefs.push({ field: 'Name', displayName: 'EMPLOYEE NAME'});
$scope.gridOptions.columnDefs.push({ field: 'Age', displayName: 'AGE'});
....

Here is the event which fires when column is moved.

http://ui-grid.info/docs/#/api/ui.grid.moveColumns.api:PublicApi

My problem is that i want to get the new order of the columns in $scope.gridOptions.columnDefs for saving it in db.

On Column Moving $scope.gridOptions.columnDefs doesn't get updated.

How to solve this?

1
  • 1
    That Plunker is very empty. Good thing is: It has no bugs:-) Commented Oct 31, 2014 at 10:43

2 Answers 2

4

You will need to get the new order from grid state. Try get the grid state using this: (remember to add 'ui.grid.saveState' module and 'ui-grid-save-state' directive)

$scope.state = $scope.gridApi.saveState.save();

Take a look at their tutorial about grid state here

Sign up to request clarification or add additional context in comments.

Comments

0

You can listen to the columnPositionChanged event:

gridApi.colMovable.on.columnPositionChanged(scope,function(colDef, originalPosition, newPosition){})

Check ui-grid documentation for more info

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.