ExtJS动态过滤ComboBox
ExtJS filter ComboBox dynamically
我有一个包含多个组合框的属性网格,我想根据前一个框中选择的内容过滤其中一个框中的值。
我的代码是这样的:
var tempPropGrid = me.getView().add(
{
xtype:'propertygrid',
width: 80,
header: false,
title: 'prop grid',
//for some reason the headers are not hiding, we may need to deal with this using CSS
//hideHeaders: true,
enableColumnResize: false,
sortableColumns: false,
nameColumnWidth: 1,
source: record.data,
sourceConfig: {
teamName: {
editor: Ext.create('Ext.form.ComboBox', {
store: teams,
queryMode: 'local',
displayField: 'teamName',
valueField: 'teamName'
}),
displayName: 'Team'
},
leadDev : {
editor: Ext.create('Ext.form.ComboBox', {
store: teamMembers.filter('teamName', teamName.value), // this probably won't work but you get the idea
queryMode: 'local',
displayField: 'personName',
valueField: 'personName'
}),
displayName: 'Lead Dev'
},
和我的JSON对象看起来像这样:
{
"periodName": "Week1",
"teamName": "tango",
"roleName": "SWE III",
"roleExperience": "3",
"id": "21ea7f61-a9a5-4dbd-b405-e7a0449f8096"
},
所以本质上我将一个项目分配给一个团队,然后根据我选择的团队,我想根据他们在该团队中选择一个leadDev。
我不知道如何摘下一个组合框的值,并动态应用一个过滤器,所以任何帮助将是伟大的。
网格中的每一行都是一个模型。因此,在leadDev
组合框中,您只需要侦听'expand'
事件,然后检索当前行模型并将该模型的值应用于过滤器。它看起来应该像这样(未选中):
Ext.create('Ext.form.ComboBox', {
store: store
queryMode: 'local',
displayField: 'personName',
valueField: 'personName',
listeners: {
'expand' : function(combo) {
var grid = combo.up('grid');
var selection = grid.getSelectionModel().getSelection();
var currentRowModel = //get this from selection
combo.getStore().clearFilter(true);
combo.getStore().filter('teamName',currentRowModel.teamName);
}
}
})
当用户从第一个组合框中选择值时,需要更新当前模型
相关文章:
- 有可能过滤来自嵌入式YouTube的声音吗
- 为什么我的d3.jsselectAll+过滤器没有过滤
- ui网格日期单元格过滤器,过滤日期格式导致显示错误的日期
- Angular:使用选择列表选择过滤代码中的对象
- 在单击时过滤 JSON
- 如何在BookshelfJS中通过加入来过滤结果
- 如何使用javascript过滤复杂的json对象
- 如何应用带过滤器的ng if来过滤记录,并在同一页面中显示两个不同的视图
- 过滤AngularJs中的数据
- 通过API调用过滤数据
- 使用angularjs内置过滤器过滤代码中的特定属性
- 如何在重建URL后从URL中传递过滤值,目的是使用Angular2和Typescript实现无限滚动
- 相对于角度控制器中的另一个阵列过滤阵列项目
- 如何在D3.js中绘制地图投影上的点,并使用范围滑块过滤数据
- 使用PHP通过HTML表单选项选择器过滤MYSQL结果
- 尝试过滤“;引号"基于'"类别“;使用流星&mongo
- Angular中的过滤和$http承诺
- 使用jquery grep过滤具有值数组的json对象
- 使用 Combobox 类别和 Textbox JavaScript 进行过滤
- ExtJS动态过滤ComboBox