最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - AngularJS - ui-grid - Column Moving - get new order of columns - Stack Overflow

programmeradmin3浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 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

You can listen to the columnPositionChanged event:

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

Check ui-grid documentation for more info

发布评论

评论列表(0)

  1. 暂无评论