I am implementing / in my application.
There is a feature of Column Moving
, where Columns can be moved.
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.
.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?
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?
Share Improve this question edited Mar 12, 2016 at 0:16 ErikE 50.3k23 gold badges155 silver badges200 bronze badges asked Oct 31, 2014 at 7:27 AnupAnup 9,75617 gold badges77 silver badges147 bronze badges 1- 1 That Plunker is very empty. Good thing is: It has no bugs:-) – mainguy Commented Oct 31, 2014 at 10:43
2 Answers
Reset to default 4You 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
You can listen to the columnPositionChanged event:
gridApi.colMovable.on.columnPositionChanged(scope,function(colDef, originalPosition, newPosition){})
Check ui-grid documentation for more info