Javascript 行内剑道网格过滤器中的剑道下拉列表
我试图将标准字符串过滤器的默认行为更改为组合框(dropdownlist) 当我使用与所需值不同的显示名称时,我遇到了一些问题 例如: 我的应用程序中有i18n,因此组合中的每个项目都应该以正确的语言显示,但特定标签引用的值必须保持不变 这是你通常所期望的 问题是我不能那样做 这是我的gridOptions的代码:Javascript 行内剑道网格过滤器中的剑道下拉列表,javascript,kendo-ui,kendo-grid,kendo-dropdown,Javascript,Kendo Ui,Kendo Grid,Kendo Dropdown,我试图将标准字符串过滤器的默认行为更改为组合框(dropdownlist) 当我使用与所需值不同的显示名称时,我遇到了一些问题 例如: 我的应用程序中有i18n,因此组合中的每个项目都应该以正确的语言显示,但特定标签引用的值必须保持不变 这是你通常所期望的 问题是我不能那样做 这是我的gridOptions的代码: public gridOptions() { return { scrollable: false, selectable: 'row',
public gridOptions() {
return {
scrollable: false,
selectable: 'row',
schema: {
model: { id: 'id' }
},
filterable: {
messages: {
isFalse: 'Is false',
isTrue: 'Is True'
}
},
columns: [{
field: 'name',
title: '{{\'name\' | translate }}'
},
{
field: 'combo',
title: '{{\'combo\' | translate }}',
filterable: {
extra: false,
operators: {
string: {
eq: 'Is Equals to'
}
},
ui: (e) => { this.filter(e) },
cell: {
showOperators: false,
template: (c) => { this.filterRow(c) },
}
}
}
]
};
}
它使用两个创建dropdownlist的函数:
private filter(element) {
this.myService.getData().then( data => {
element.kendoDropDownList(
{
dataTextField: 'displayName',
dataValueField: 'name',
dataSource: data,
optionLabel: '--select a value--'
}
};
});
}
private filterRow(container) {
this.filter(container.element);
}
我所期望的是过滤器显示翻译后的字段(例如:名称为“绿色”时为绿色),并且使用“名称”属性的值进行过滤
相反,当我在组合框中选择某个内容时,选择并不是,所有内容都被过滤器隐藏
奇怪的是,如果我使用字段“name”作为dataTextField,使用任何其他字段作为dataValueField(我使用“isworkingfornoreason”作为字段!!),一切都正常。过滤器可以工作,但combobox元素显然是默认字符串,而不是翻译的
你能帮我弄清楚发生了什么吗?尝试使用
模板
呈现列表选项。有时dataTextField
有缺陷。你能展示一下你的getData().then()
promise里面的data
是什么吗?它是一个具有各种属性的对象数组,其中一个是displayName,另一个是'name'