2016-04-05 19 views
0

私はUI Gridを使用しています。並べ替え/列の移動/並べ替えを防止する

  1. に固定された最初の3列私は移動することができるようにしたい:私はplnkr here、私は次のことを達成したい

    var app = angular.module('app', ['ngTouch', 'ui.grid', 'ui.grid.pinning', 'ui.grid.moveColumns']); 
    
    app.controller('MainCtrl', ['$scope', '$http', '$log', function ($scope, $http, $log) { 
        $scope.gridOptions = {}; 
    
        $scope.gridOptions.columnDefs = [ 
        { name:'id', width:50, pinnedLeft:true }, 
        { name:'name', width:100, pinnedLeft:true }, 
        { name:'age', width:100, pinnedLeft:true }, 
        { name:'company', width:100}, 
        { name:'address.street', width:150 }, 
        { name:'address.city', width:150 }, 
        { name:'address.state', width:50 }, 
        { name:'address.zip', width:50 }, 
        { name:'email', width:100 }, 
        { name:'phone', width:200 }, 
        { name:'about', width:300 }, 
        { name:'friends[0].name', displayName:'1st friend', width:150 }, 
        { name:'friends[1].name', displayName:'2nd friend', width:150 }, 
        { name:'friends[2].name', displayName:'3rd friend', width:150 }, 
        ]; 
        $scope.gridOptions.jqueryUIDraggable= false; 
    
        $http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json') 
        .success(function(data) { 
         $scope.gridOptions.data = data; 
        }); 
    }]); 
    

    を、持っています他の固定されていない列をドラッグ・ドロップすることで

私は両方を達成できました。

しかし、固定されている列のドラッグドロップをSTOP /防止できませんでした。 特定の列がドラッグ・ドロップされないようにするにはどうすればよいですか?

答えて

0

app.jsでは、enableColumnMoving追加してみてください:columnDefsに偽そうのように:

ここ
var app = angular.module('app', ['ngTouch', 'ui.grid', 'ui.grid.pinning', 'ui.grid.moveColumns']); 

app.controller('MainCtrl', ['$scope', '$http', '$log', function ($scope, $http, $log) { 
    $scope.gridOptions = {}; 

$scope.gridOptions.columnDefs = [ 
{ name:'id', width:50, pinnedLeft:true, enableColumnMoving:false }, 
{ name:'name', width:100, pinnedLeft:true, enableColumnMoving:false }, 
{ name:'age', width:100, pinnedLeft:true, enableColumnMoving:false }, 
{ name:'company', width:100}, 
{ name:'address.street', width:150 }, 
{ name:'address.city', width:150 }, 
{ name:'address.state', width:50 }, 
{ name:'address.zip', width:50 }, 
{ name:'email', width:100 }, 
{ name:'phone', width:200 }, 
{ name:'about', width:300 }, 
{ name:'friends[0].name', displayName:'1st friend', width:150 }, 
{ name:'friends[1].name', displayName:'2nd friend', width:150 }, 
{ name:'friends[2].name', displayName:'3rd friend', width:150 }, 
];  

$http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json') 
.success(function(data) { 
    $scope.gridOptions.data = data; 
}); 
}]); 
+0

がPlunker [リンク](http://plnkr.co/edit/C4awJEATlm3JrqZ03Gwf?p=previewです) – dovelce

+0

クール!これはまさに私が探していたものです。 :) –

関連する問題