2017-03-08 9 views
1

グリッド内のデータに基づいて条件付きカラーリングを適用したい。 これはcolumnDefsのcellClass関数を使っています。 私の問題は、これらのクラスは選択の変更時に更新されず、私は選択された行に色を定義することができず、条件付き色付けもしていないということです。 したがって、いくつかの行はデータに基づいて赤色に着色され、選択されるとその色が暗くなり、選択と条件も表示されます。角型UIグリッドの条件付きカラー選択

これを達成する方法はありますか?

これは、イムが何しようとするものですが、明らかにそれは、この関数として文句を言わない作業が選択変更で呼び出されていません。

vm.getCellHighlight = function(grid, row, col, rowRenderIndex, colRenderIndex) { 
     var rowStatus = row.entity.isChild ? grid.parentRow.entity.transactionItemStatus : row.entity.transactionItemStatus; 
     var rowSelected = row.isSelected ? 'Selected' : ''; 
     var rowType = ''; 
     if (rowStatus == ticketStateStorno){ 
      rowType = 'Storno'; 
     } 
     if (rowStatus == ticketStateUsed){ 
      rowType = 'Used'; 
     } 
     return (rowRenderIndex % 2)? 'searchSalesGridHighlight' + rowType + 'Dark' + rowSelected : 'searchSalesGridHighlight' + rowType + 'Light' + rowSelected; 
    }; 

答えて

1

私は、これは、ビット単位あなたが望むものに近いかもしれないと考えています。

angularjs ui-grid row color template

のJavaScript/AngularJSコントローラー:

app.controller('MainCtrl', ['$scope', '$http', function($scope, $http) { 
    var colorRowTemplate = 
    //same as normal template, but extra ng-class for old people: 'old-people':(row.entity.Age>25&&!row.isSelected), 'old-people-selected':(row.entity.Age>25&&row.isSelected) 
    "<div ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{'old-people':(row.entity.Age>25&&!row.isSelected), 'old-people-selected':(row.entity.Age>25&&row.isSelected), 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>"; 
    $scope.gridOptions = { 
    enableSelectAll: true, 
    enableRowSelection: true, 
    enableRowHeaderSelection: false, 
    enableFullRowSelection: true, 
    rowTemplate: colorRowTemplate, 
    showGridFooter: true 
    } 
    $http.get('data.json') 
    .then(function(response) { 
     $scope.gridOptions.data = response.data; 
    }); 
}]); 

ここで働いてPlunker、http://plnkr.co/edit/Yt7jQf6044YKzyG2CJtg?p=previewです。

+0

ありがとう、ちょうど近いが、正確に私が必要なもの! – bitwise