本文介绍了如何在ExtJS中使用绑定公式内的逻辑运算符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表单中的3个输入字段,并希望仅在前两个输入有值时启用第三个输入。
这似乎不起作用:
Ext.define('MyApp.view.myobj.MyPanel',{
extend:'Ext.Panel ',
viewModel:{},
items:[{
xtype:'form',
defaultType:'textfield',
项目:[
{fieldLabel:'Field 1',reference:'field1',published:'value'},
{fieldLabel:'Field 2',reference:'field2',published:值'},
{
fieldLabel:'Field 3',
bind:{
disabled:'{!field1.value} || {!field2.value}'
}
},
],
}],
});
解决方案
在视图模型中,添加一个公式返回{! field1.value} ||
viewModel:{
formula:{
something:{
bind:{
x:'{!field1.value}',
y:'{!field2.value} '
},
get:function(data){
if(data.x || data.y)return true;
else return false;
}
}
}
},
items:[{
xtype:'form',
defaultType:' textfield',
bodyPadding:10,
items:[
{fieldLabel:'Field 1',reference:'field1',published:'value'},
{fieldLabel: 'field 2',引用:'field2',发布:'value'},
{
fieldLabel:'Field 3',
bind:{
disabled: }
}
},
],
}]
I have 3 input fields in a form and want to make the third input enabled only when the first two inputs have values.
This doesn't seem to work:
Ext.define('MyApp.view.myobj.MyPanel', {
extend:'Ext.Panel',
viewModel: {},
items: [{
xtype: 'form',
defaultType: 'textfield',
items: [
{fieldLabel: 'Field 1', reference: 'field1', publishes: 'value'},
{fieldLabel: 'Field 2', reference: 'field2', publishes: 'value'},
{
fieldLabel: 'Field 3',
bind: {
disabled: '{!field1.value} || {!field2.value}'
}
},
],
}],
});
解决方案
In the view model, add a formula to return the value for {!field1.value} || {!field1.value}
As per the fiddle:
viewModel: {
formulas: {
something: {
bind: {
x: '{!field1.value}',
y: '{!field2.value}'
},
get: function (data) {
if (data.x || data.y) return true;
else return false;
}
}
}
},
items: [{
xtype: 'form',
defaultType: 'textfield',
bodyPadding: 10,
items: [
{fieldLabel: 'Field 1', reference: 'field1', publishes: 'value'},
{fieldLabel: 'Field 2', reference: 'field2', publishes: 'value'},
{
fieldLabel: 'Field 3',
bind: {
disabled: "{something}"
}
},
],
}]
这篇关于如何在ExtJS中使用绑定公式内的逻辑运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!