AngularJS:ui网格使用过滤器在单元格中显示多行

时间:2017-03-27 12:51:38

标签: angularjs angular-ui-grid

我无法在列中渲染新行.Below是我的代码。

tests = "TC2148 (test1),TC2150 (test2),TC2149 (test3)";

    { field:'tests', displayName:'TestID's', cellTooltip: true, minWidth:110, visible: true  , cellFilter : 'filterTests:this' }

    testApp.filter('filterTests',function(){
        return function(value){
            value = value.replace(/ *\([^)]*\) */g, "")
                                  .replace(/,/g,"\n");  
           return value;
        }
    });

1 个答案:

答案 0 :(得分:0)

只需进行一些小调整:



- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40)];
    NSDictionary *data = [categoryArray objectAtIndex:section];
    return view;    
}

var testApp = angular.module('testApp', ['ui.grid', 'ngSanitize']);
testApp.controller('MainCtrl', ['$scope', '$sce', function($scope, $sce) {
  var tests = "TC2148 (test1),TC2150 (test2),TC2149 (test3)";
  $scope.gridOptions = {
    rowHeight: 80,
    columnDefs: [{
      field: 'tests',
      displayName: 'TestID\'s',
      cellTooltip: true,
      minWidth: 110,
      visible: true,
      cellTemplate: "<div class=\"ui-grid-cell-contents\" title=\"TOOLTIP\"><span ng-bind-html=\"grid.appScope.filter(COL_FIELD CUSTOM_FILTERS)\"></span></div>",
    }],
    data: [{
      tests: tests
    }]
  }
  $scope.filter = function(value) {
    return value.replace(/ *\([^)]*\) */g, "")
      .replace(/,/g, "<br>");
  };
}]);
&#13;
div[ui-grid] {
  height: 140px;
  width: 150px;
}
&#13;
&#13;
&#13;

如果您有任何其他问题,请与我们联系。

乐意帮忙!