【问题标题】:Sencha Touch how to do conditional listeners for a selectfieldSencha Touch 如何为选择字段做条件监听器
【发布时间】:2016-05-09 06:58:11
【问题描述】:

好的,这是我的问题。我有一个带有一些选项的选择字段。选择字段用于过滤我的列表。所以在选择字段中有按纪律过滤。当用户选择它时,将显示当前隐藏的学科字段,但是当用户选择按学生过滤时,学科字段将隐藏自己,而学生字段(也被隐藏)将显示。但我似乎无法弄清楚代码。顺便说一句,我是煎茶触摸的新手。我正在使用 sencha touch 2.4.2。这是我的代码:-

{
                        //first item of vbox(1)
                        xtype: 'container',
                        layout: 'hbox',
                        style: 'background-color:' + _ListHeaderColor() + '; color: floralwhite;',
                        margin: '10 10',
                        items: [
                            {
                                //first item of hbox
                                html: "Request List (Request Patient)",
                                margin: '15 15',
                                flex: 1
                            }, //end of first item of hbox
                            {
                                //second item of hbox
                                xtype: 'selectfield',
                                id: 'choose',
                                name: 'filter',
                                label: 'Filter By',
                                margin: '5 5',
                                width: '20%',
                                options: [
                                            { text: '-', value: 'none' },
                                            { text: 'Discipline', value: 'disc' },
                                            { text: 'Student', value: 'stud' },
                                ],
                            listeners: {
                                change: function (field, newValue) {
                                    if (value) {
                                        var disp = Ext.getCmp(newValue).show();
                                        var disp = Ext.getCmp(newValue).hide();
                                    }
                                    else {
                                        var disp = Ext.getCmp(newValue).show();
                                        var disp = Ext.getCmp(newValue).hide();
                                    }
                                }
                            }
                        },
                        {
                            xtype: 'selectfield',
                            id: 'disc',
                            name: 'discipline',
                            label: 'Discipline',
                            margin: '5 5',
                            hidden: true,

                            store: _DataStore_RequestPatient,
                            displayField: 'text',
                            valueField: 'value'
                        },
                        {
                            xtype: 'searchfield',
                            id: 'stud',
                            name: 'student',
                            label: 'Students',
                            hidden: true
                        }
                    ]
                },

【问题讨论】:

    标签: extjs touch sencha-touch-2


    【解决方案1】:

    好吧,您应该提供您收到的错误消息。你应该已经发现了

    值未定义

    但这只是冰山一角。出于礼貌,我已经为您修改了代码。

    https://fiddle.sencha.com/#fiddle/1a1h

    【讨论】:

    • 非常感谢!!我被困了这么久。所以你就是这样做的。非常感谢。先生,我向您致以最深切的谢意。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多