Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs 使用if-else选择xtype_Extjs - Fatal编程技术网

Extjs 使用if-else选择xtype

Extjs 使用if-else选择xtype,extjs,Extjs,我正在尝试extjs中的新功能,我想根据从数据库发送的值选择xtype。该值是布尔值。所以,当它为false时,我希望xtype被隐藏,当它为true时,则为button 大概是这样的: if (valuefield == false){ xtype: 'hidden' } else{ xtype: 'button' } 我知道value字段包含false或true,但是当if-else是add时,会弹出错误,如何使它与if-else语句一起工作 这是我的代码: 文本:“管理员”

我正在尝试extjs中的新功能,我想根据从数据库发送的值选择xtype。该值是布尔值。所以,当它为false时,我希望xtype被隐藏,当它为true时,则为button

大概是这样的:

if (valuefield == false){
    xtype: 'hidden'
}
else{
   xtype: 'button'
}
我知道value字段包含false或true,但是当if-else是add时,会弹出错误,如何使它与if-else语句一起工作

这是我的代码:

文本:“管理员”

xtype: 'button',                                    
href: 'admin',
hrefTarget: '_self',                

queryMode : 'local',

valueField: 'admin',
store: Ext.create('Ext.data.Store',
{
 fields: ['admin'],
autoLoad: true,
proxy:
{
    type: 'ajax',
    url: 'admin/premision',
    reader:
    {
        type: 'json',
        root: 'data'
    }
}

在以下情况下,您应该能够使用内联命令:

xtype: valueField ? 'button' : 'hidden'
尽管设置隐藏属性可能更可取:

xtype: 'button',
hidden: valueField ? false : true

在以下情况下,您应该能够使用内联命令:

xtype: valueField ? 'button' : 'hidden'
尽管设置隐藏属性可能更可取:

xtype: 'button',
hidden: valueField ? false : true

希望这把小提琴能给你一些想法-


希望这把小提琴能给你一些想法-