Meteor 为什么';当过滤器激活时,角流星中的ui网格是否显示其数据?
你好,我有个问题 工作:Meteor 为什么';当过滤器激活时,角流星中的ui网格是否显示其数据?,meteor,angular-ui-grid,angular-meteor,Meteor,Angular Ui Grid,Angular Meteor,你好,我有个问题 工作: 流星 角流星 用户界面网格 我遵循文档ui网格中的plunker示例 问题是当过滤器被激活时,数据不会显示 我在控制台中没有错误 我把我的代码: html文件 <button id='toggleFiltering' ng-click="inventario.toggleFiltering()" class="btn btn-success">Toggle Filtering</button> <div id="grid1" ui-gr
- 流星
- 角流星
- 用户界面网格
<button id='toggleFiltering' ng-click="inventario.toggleFiltering()" class="btn btn-success">Toggle Filtering</button>
<div id="grid1" ui-grid="inventario.gridOptions" class="grid"></div>
class Inventario {
constructor($scope, $reactive, $uibModal, $http, uiGridConstants) {
'ngInject';
$reactive(this).attach($scope);
this.$uibModal = $uibModal;
var today = new Date();
var nextWeek = new Date();
this.highlightFilteredHeader = (row, rowRenderIndex, col, colRenderIndex) => {
if( col.filters[0].term ){
return 'header-filtered';
} else {
return '';
}
};
this.gridOptions = {
enableFiltering: true,
onRegisterApi: (gridApi) => {
this.gridApi = gridApi;
},
columnDefs: [
// default
{ field: 'name', headerCellClass: this.highlightFilteredHeader },
// pre-populated search field
{ field: 'gender', filter: {
term: '1',
type: uiGridConstants.filter.SELECT,
selectOptions: [ { value: '1', label: 'male' }, { value: '2', label: 'female' }, { value: '3', label: 'unknown'}, { value: '4', label: 'not stated' }, { value: '5', label: 'a really long value that extends things' } ]
},
cellFilter: 'mapGender', headerCellClass: this.highlightFilteredHeader },
// no filter input
{ field: 'company', enableFiltering: false, filter: {
noTerm: true,
condition: (searchTerm, cellValue) => {
return cellValue.match(/a/);
}
}},
// specifies one of the built-in conditions
// and a placeholder for the input
{
field: 'email',
filter: {
condition: uiGridConstants.filter.ENDS_WITH,
placeholder: 'ends with'
}, headerCellClass: this.highlightFilteredHeader
},
// custom condition function
{
field: 'phone',
filter: {
condition: (searchTerm, cellValue) => {
var strippedValue = (cellValue + '').replace(/[^\d]/g, '');
return strippedValue.indexOf(searchTerm) >= 0;
}
}, headerCellClass: this.highlightFilteredHeader
},
// multiple filters
{ field: 'age', filters: [
{
condition: uiGridConstants.filter.GREATER_THAN,
placeholder: 'greater than'
},
{
condition: uiGridConstants.filter.LESS_THAN,
placeholder: 'less than'
}
], headerCellClass: this.highlightFilteredHeader},
// date filter
{ field: 'mixedDate', cellFilter: 'date', width: '15%', filter: {
condition: uiGridConstants.filter.LESS_THAN,
placeholder: 'less than',
term: nextWeek
}, headerCellClass: this.highlightFilteredHeader
},
{ field: 'mixedDate', displayName: "Long Date", cellFilter: 'date:"longDate"', filterCellFiltered:true, width: '15%',
}
]
};
$http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json')
.success((data) => {
this.gridOptions.data = data;
this.gridOptions.data[0].age = -5;
data.forEach( function addDates( row, index ){
row.mixedDate = new Date();
row.mixedDate.setDate(today.getDate() + ( index % 14 ) );
row.gender = row.gender==='male' ? '1' : '2';
});
});
this.toggleFiltering = () => {
this.gridOptions.enableFiltering = !this.gridOptions.enableFiltering;
this.gridApi.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );
};
}
}
const name = 'inventario';
// Módulo
export default angular
.module(name, [
uiRouter,
EditarArticulo
])
.component(name, {
templateUrl: `imports/ui/components/${name}/${name}.html`,
controllerAs: name,
controller: Inventario
})
.config(config)
.filter('mapGender', function() {
var genderHash = {
1: 'male',
2: 'female'
};
return function(input) {
if (!input){
return '';
} else {
return genderHash[input];
}
};
});
如果禁用筛选时一切都正常,那么您声明的(多个)筛选器肯定有问题 它很可能是排除所有数据的过滤器的组合。首先注释掉所有的过滤器(您应该看到所有的数据),然后逐个重新引入过滤器,直到您再次看到问题
这将缩小问题的范围,并允许您查看哪个筛选器出错。如果禁用筛选时一切都正常,那么您所声明的(多个)筛选器肯定有问题 它很可能是排除所有数据的过滤器的组合。首先注释掉所有的过滤器(您应该看到所有的数据),然后逐个重新引入过滤器,直到您再次看到问题
这将缩小问题的范围,并允许您查看哪个过滤器是错误的。很好的建议!谢谢问题是“混合的”!现在过滤器工作正常。再次感谢!不用担心,请将我的答案标记为正确,谢谢!是的,当然,(+1)还不够?或者,我必须做些什么才能将Answare标记为正确的?我感谢+1,感谢堆(我不知道是谁标记的)。投票向上/向下按钮下方还有一个勾号-这将标记为正确答案尼斯建议!谢谢问题是“混合的”!现在过滤器工作正常。再次感谢!不用担心,请将我的答案标记为正确,谢谢!是的,当然,(+1)还不够?或者,我必须做些什么才能将Answare标记为正确的?我感谢+1,感谢堆(我不知道是谁标记的)。投票向上/向下按钮下方还有一个勾号-这将标记为正确答案