Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular ui grid ui grid columnDefs:如何将单元格内容转换为用户友好的、数据函数的值?_Angular Ui Grid_Ui Grid - Fatal编程技术网

Angular ui grid ui grid columnDefs:如何将单元格内容转换为用户友好的、数据函数的值?

Angular ui grid ui grid columnDefs:如何将单元格内容转换为用户友好的、数据函数的值?,angular-ui-grid,ui-grid,Angular Ui Grid,Ui Grid,我有这个==> $scope.uiGrid306 = { rowTemplate:rowtpl, columnDefs: [{ field: '_ab_area', name: 'Area', width: "7%" , filter: { type: uiGridConstants.filter.SELECT, selectOptions: AREAS } }, { ... }, { field

我有这个==>

$scope.uiGrid306 = {
    rowTemplate:rowtpl,
    columnDefs: [{
        field: '_ab_area', name: 'Area', width: "7%"
        , filter: { type: uiGridConstants.filter.SELECT, selectOptions: AREAS } 
        }, { ...

        }, {
        field: '_ab_x_style', name: 'Groups', width: "5%"
        , filter: { type: uiGridConstants.filter.SELECT, selectOptions: RISKS, condition: uiGridConstants.filter.EXACT
        } 
    } 
    ]//columnDefs
    , enableFiltering: true
};//-->gridOptions

但是我的ab_x_风格的数据并不像我希望的那样友好。所以我需要一个函数来将这些数据翻译成用户友好的单词。问题是如何???

为此,需要对单元格内容应用。还有一个translate函数,用于下拉选项,其中也包含那些非用户友好的数据

cellFilter是应用于每个单元格内容的筛选器

$scope.uiGrid306 = {
    rowTemplate:rowtpl,
    columnDefs: [{
        field: '_ab_area', name: 'Area', width: "7%"
        , filter: { type: uiGridConstants.filter.SELECT, selectOptions: AREAS } 
        }, { ...

        }, {
        field: '_ab_x_style', name: 'Groups', width: "5%", cellFilter: 'TranslateMe'
        , filter: { type: uiGridConstants.filter.SELECT, selectOptions: RISKS, condition: uiGridConstants.filter.EXACT
        } 
    } 
    ]//columnDefs
    , enableFiltering: true
};//-->gridOptions
在角度控制器之后,通过

Yours.controller('BodyController', function($scope, $http, $filter, uiGridConstants, $timeout, $resource) {

})
.filter( 'TranslateMe', function (){
    return(function(value){
        return((value=='dataExcep'?'red':(value=='dataExcepLblueNoVal'?'blue':(value=='dataExcepYellowRevHi'?'yellow':(value=='dataExcepNew'?'aqua':'neutral')))));
    });
});
然后,对于下拉选项,还必须应用函数

function TranslateMe(value){
    return((value=='dataExcep'?'red':(value=='dataExcepLblueNoVal'?'blue':(value=='dataExcepYellowRevHi'?'yellow':'neutral'))));
}
为您的选择建筑本身

function loadOptions( $scope, serverdata ){

    _.forEach( _.sortBy( _.uniq( _.pluck( serverdata, '_ab_x_style' ))  ), function ( eachOpt )    {
        RISKS.push( { value: eachOpt, label: TranslateMe(eachOpt) } )
    } );
    $scope.uiGrid306.columnDefs[10].filter.selectOptions = RISKS;
}
结果(不是用户不友好的数据,而是颜色的名称)--