链式组合框有可能 select child cb 没有 parent
Chained comboboxes with possibility to select child cb without parent
所以基本上我正在尝试做与我在上一个问题中所做的相同的事情 -
但是现在我希望能够 select child combo 而无需选择 parent.
这是我为进行基本过滤所做的工作,但我一直在努力使 select child cb.
成为可能
Ext.define('AppTest.CategoryViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.category',
stores: {
categories: {
fields: ['id', 'name'],
proxy: {
type: 'ajax',
url: 'categories.json',
reader: {
type: 'json'
}
}
},
users: {
storeId: 'userStore',
fields: ['id', 'category_id', 'number'],
autoLoad: true,
filters: [{
property:'category_id',
disabled: '{!categoryCombo.selection}',
//disableOnEmpty:true,
value: '{categoryCombo.selection.id}',
/*filter: function (item) {
var me = this,
filterFn = me._filterFn || me.getFilterFn(),
convert = me.getConvert(),
value = me._value;
me._filterValue = value;
console.log(value);
me.isDateValue = Ext.isDate(value);
if (me.isDateValue) {
me.dateValue = value.getTime();
}
if (convert && !me.preventConvert[me.getOperator()]) {
me._filterValue = convert.call(me.scope || me, value);
}
return filterFn.call(me.scope || me, item);
},*/
//extjs is seems to be bugged here, disable doesn't work without it.
updateDisableOnEmpty: function(disableOnEmpty) {
var disabled = this.getDisabled();
if (disableOnEmpty) {
disabled = Ext.isEmpty(this.getValue());
}
this.setDisabled(disabled);
}
//filterFn:function(item){
//console.log(new Error().stack);
//}
}],
proxy: {
type:'ajax',
url:'users.json',
reader: {
type:'json'
}
}
}
}
});
https://fiddle.sencha.com/#fiddle/103r
我错过了什么?
自己做的
所以我必须在父配置中定义发布者:
users: {
alias:'store.users',
fields: ['id', 'category_id', 'number'],
autoLoad: true,
filters: [{
property:'category_id',
value: '{categoryCombo.value}',
//disabled: '{!categoryCombo.selection}',
disableOnEmpty:true,
//filter: function (item) {
// var me = this,
// filterFn = me._filterFn || me.getFilterFn(),
// convert = me.getConvert(),
// value = me._value;
// me._filterValue = value;
// console.log(value);
// me.isDateValue = Ext.isDate(value);
// if (me.isDateValue) {
// me.dateValue = value.getTime();
// }
// if (convert && !me.preventConvert[me.getOperator()]) {
// me._filterValue = convert.call(me.scope || me, value);
// }
//
// return filterFn.call(me.scope || me, item);
//},
updateDisableOnEmpty: function(disableOnEmpty) {
var disabled = this.getDisabled();
if (disableOnEmpty) {
disabled = Ext.isEmpty(this.getValue());
}
this.setDisabled(disabled);
}
//filterFn:function(item){
//console.log(new Error().stack);
//}
}],
proxy: {
type:'ajax',
url:'resources/data/users.json',
reader: {
type:'json'
}
}
}
{
// store: 'categories',
bind: {
store: '{categories}'
},
xtype: 'combo',
reference: 'categoryCombo',
displayField: 'name',
valueField:'id',
publishes:'value',
name: 'category',
typeAhead: false,
fieldLabel: 'Category',
emptyText: 'Select a category...',
anchor: '95%'
},
{
xtype: 'combo',
name: 'user',
reference: 'userCombo',
fieldLabel: 'User',
displayField: 'number',
valueField: 'id',
hiddenName: 'id',
emptyText: 'Select a user...',
anchor: '95%',
//store: {
// type:'users'
//},
bind: {
fieldLabel: '{categoryCombo.selection.name}',
//filters: [{
// property:'category_id',
// value: '{categoryCombo.value}'
// //disabled: '{!categoryCombo.selection}',
// //disableOnEmpty:true
//}],
store: '{users}'
},
listeners: {
change: 'onSelectChange'
}
}
在幕后,这个配置和绑定存储之间有什么区别?绑定对性能有何影响?这是angular吗?
所以基本上我正在尝试做与我在上一个问题中所做的相同的事情 -
这是我为进行基本过滤所做的工作,但我一直在努力使 select child cb.
成为可能 Ext.define('AppTest.CategoryViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.category',
stores: {
categories: {
fields: ['id', 'name'],
proxy: {
type: 'ajax',
url: 'categories.json',
reader: {
type: 'json'
}
}
},
users: {
storeId: 'userStore',
fields: ['id', 'category_id', 'number'],
autoLoad: true,
filters: [{
property:'category_id',
disabled: '{!categoryCombo.selection}',
//disableOnEmpty:true,
value: '{categoryCombo.selection.id}',
/*filter: function (item) {
var me = this,
filterFn = me._filterFn || me.getFilterFn(),
convert = me.getConvert(),
value = me._value;
me._filterValue = value;
console.log(value);
me.isDateValue = Ext.isDate(value);
if (me.isDateValue) {
me.dateValue = value.getTime();
}
if (convert && !me.preventConvert[me.getOperator()]) {
me._filterValue = convert.call(me.scope || me, value);
}
return filterFn.call(me.scope || me, item);
},*/
//extjs is seems to be bugged here, disable doesn't work without it.
updateDisableOnEmpty: function(disableOnEmpty) {
var disabled = this.getDisabled();
if (disableOnEmpty) {
disabled = Ext.isEmpty(this.getValue());
}
this.setDisabled(disabled);
}
//filterFn:function(item){
//console.log(new Error().stack);
//}
}],
proxy: {
type:'ajax',
url:'users.json',
reader: {
type:'json'
}
}
}
}
});
https://fiddle.sencha.com/#fiddle/103r
我错过了什么?
自己做的
所以我必须在父配置中定义发布者:
users: {
alias:'store.users',
fields: ['id', 'category_id', 'number'],
autoLoad: true,
filters: [{
property:'category_id',
value: '{categoryCombo.value}',
//disabled: '{!categoryCombo.selection}',
disableOnEmpty:true,
//filter: function (item) {
// var me = this,
// filterFn = me._filterFn || me.getFilterFn(),
// convert = me.getConvert(),
// value = me._value;
// me._filterValue = value;
// console.log(value);
// me.isDateValue = Ext.isDate(value);
// if (me.isDateValue) {
// me.dateValue = value.getTime();
// }
// if (convert && !me.preventConvert[me.getOperator()]) {
// me._filterValue = convert.call(me.scope || me, value);
// }
//
// return filterFn.call(me.scope || me, item);
//},
updateDisableOnEmpty: function(disableOnEmpty) {
var disabled = this.getDisabled();
if (disableOnEmpty) {
disabled = Ext.isEmpty(this.getValue());
}
this.setDisabled(disabled);
}
//filterFn:function(item){
//console.log(new Error().stack);
//}
}],
proxy: {
type:'ajax',
url:'resources/data/users.json',
reader: {
type:'json'
}
}
}
{
// store: 'categories',
bind: {
store: '{categories}'
},
xtype: 'combo',
reference: 'categoryCombo',
displayField: 'name',
valueField:'id',
publishes:'value',
name: 'category',
typeAhead: false,
fieldLabel: 'Category',
emptyText: 'Select a category...',
anchor: '95%'
},
{
xtype: 'combo',
name: 'user',
reference: 'userCombo',
fieldLabel: 'User',
displayField: 'number',
valueField: 'id',
hiddenName: 'id',
emptyText: 'Select a user...',
anchor: '95%',
//store: {
// type:'users'
//},
bind: {
fieldLabel: '{categoryCombo.selection.name}',
//filters: [{
// property:'category_id',
// value: '{categoryCombo.value}'
// //disabled: '{!categoryCombo.selection}',
// //disableOnEmpty:true
//}],
store: '{users}'
},
listeners: {
change: 'onSelectChange'
}
}
在幕后,这个配置和绑定存储之间有什么区别?绑定对性能有何影响?这是angular吗?