1
我正在与角ui网格库和面临的问题。我无法理解如何为具有多个值的单元格应用过滤器。 栏目种类具有内部阵列,这是我显示直通cellTemplate这样选择过滤器无法与cellTemplate,角度ui网格
cellTemplate: "<div ng-repeat='item in row.entity[col.field]'>{{item.name}}</div>"
也类别栏我有一个动态数组选择滤波器,这我得到通服务
filter: {
type: uiGridConstants.filter.SELECT,
selectOptions: $scope.categories
},
其中$ scope.categories来自
lovServices.categories().then(function (result) {
angular.forEach(result, function (value) {
$scope.categories.push({
value: value.id,
label: value.name
});
});
});
但是,当我选择任何类别筛选它让我看到一个空网,据我所知,电网滤波器不能找到任何价值,但它的原因我不明白。
有人能帮我找到我的错误吗?我感谢任何帮助。
代码:
app.controller('MainCtrl', function ($scope, $http, uiGridConstants, lovServices) {
$scope.categories = [];
// Get Grid Data
var getData = function() {
lovServices.eventTypes()
.then(function (response) {
//Initial Data
$scope.gridOptions.data = response;
});
};
var getOptions = function() {
lovServices.categories().then(function (result) {
angular.forEach(result, function (value) {
$scope.categories.push({
value: value.id,
label: value.name
});
});
});
};
// Ui-Grid Options
$scope.gridOptions = {
enableFiltering: true,
rowHeight: 60
};
// Ui-Grid Columns
$scope.gridOptions.columnDefs = [
{
displayName: 'Name',
field: 'name',
sort: {
direction: uiGridConstants.ASC
}
},
{
field: 'description',
},
{
field: 'category',
enableSorting: false,
filter: {
type: uiGridConstants.filter.SELECT,
selectOptions: $scope.categories
},
cellTemplate: "<div ng-repeat='item in row.entity[col.field]'>{{item.name}}</div>"
}
];
$scope.gridOptions.onRegisterApi = function (gridApi) {
$scope.gridApi = gridApi;
};
//Get data
getData();
getOptions();
});
This is a plunker与我的问题
条件,就是这样我不明白如何申请,我曾尝试在中filterChanged上强烈冲击直通for循环电网核心,但没有取得任何成功。非常感谢您的帮助!我必须更仔细地阅读文档。 – antonyboom