如何过滤 Angular Ui 网格中的每一行下拉值
How to filter each row dropdown values in Angular Ui Grid
我几年前开始使用 ui-grid,所以我遇到了一些问题。
我想过滤网格每一行下拉列表中的选项。
我可以过滤值并将其显示在下拉字段中,但是当我在下拉列表中单击时,只会出现未定义的值。我能做些什么来解决这个问题?
我已经尝试了很多东西,但我找不到解决方案。
这里是 plunker
http://embed.plnkr.co/HMsq4OasNs50ywJuI3DS/
谢谢
我分叉了你的plunker。
总而言之,我更改了列定义以使用 editDropdownOptionsFunction 而不是 editDropdownOptionsArray 和 cellFilter 的组合。根据文档,
cellFilter is a filter to apply to the content of each cell
...所以这看起来不像您想要实现的目标。
此外,将 rowEntity.sindicato === 1 的周期定义更改为数组而不是对象。
editDropdownOptionsFunction: function(rowEntity, colDef) {
console.log(rowEntity);
if (rowEntity.sindicato === 1) {
periodos = [{
id: 1,
value: 'teste1'
}];
} else if (rowEntity.sindicato === 2) {
periodos = [{
id: 2,
value: 'test2'
}, {
id: 5,
value: 'test5'
}];
} else {
periodos = [{
id: 3,
value: 'test3'
}, {
id: 6,
value: 'test6'
}, {
id: 4,
value: 'test4'
}];
}
return periodos;
}
我几年前开始使用 ui-grid,所以我遇到了一些问题。 我想过滤网格每一行下拉列表中的选项。 我可以过滤值并将其显示在下拉字段中,但是当我在下拉列表中单击时,只会出现未定义的值。我能做些什么来解决这个问题? 我已经尝试了很多东西,但我找不到解决方案。
这里是 plunker
http://embed.plnkr.co/HMsq4OasNs50ywJuI3DS/
谢谢
我分叉了你的plunker。
总而言之,我更改了列定义以使用 editDropdownOptionsFunction 而不是 editDropdownOptionsArray 和 cellFilter 的组合。根据文档,
cellFilter is a filter to apply to the content of each cell
...所以这看起来不像您想要实现的目标。
此外,将 rowEntity.sindicato === 1 的周期定义更改为数组而不是对象。
editDropdownOptionsFunction: function(rowEntity, colDef) {
console.log(rowEntity);
if (rowEntity.sindicato === 1) {
periodos = [{
id: 1,
value: 'teste1'
}];
} else if (rowEntity.sindicato === 2) {
periodos = [{
id: 2,
value: 'test2'
}, {
id: 5,
value: 'test5'
}];
} else {
periodos = [{
id: 3,
value: 'test3'
}, {
id: 6,
value: 'test6'
}, {
id: 4,
value: 'test4'
}];
}
return periodos;
}