Sencha Touch Picker的实施?

时间:2011-05-25 17:17:40

标签: sencha-touch extjs picker

我正在使用SenchaTouch,并希望将他们的Picker用于UI组件。我有这段代码:

        var datePicker = new Ext.Picker({
        slots: [
            {
            name : 'limit_speed',
            useTitles: true,
            title: 'Terminals',
                data : [
                    {text: 'Terminalq 1', value: 1},
                    {text: 'Terminal 2', value: 2},
                    {text: 'Terminal 3', value: 3},
                    {text: 'Terminal 4', value: 4}
                ]    
            }    
        ]

    });

有谁知道如何让事件处理程序在doneButton上工作?

3 个答案:

答案 0 :(得分:1)

向更改事件添加功能。

datePicker.on('change', function(){
  // do some stuff
});

var datePicker = new Ext.Picker({
        slots: [
            {
            name : 'limit_speed',
            useTitles: true,
            title: 'Terminals',
                data : [
                    {text: 'Terminalq 1', value: 1},
                    {text: 'Terminal 2', value: 2},
                    {text: 'Terminal 3', value: 3},
                    {text: 'Terminal 4', value: 4}
                ]    
            }    
        ],   
        listeners: {
            change: {
                element: 'el', //bind to the underlying el property on the panel
                fn: function(){ console.log('click el'); }
            }
        }
});

你也可以将它添加到'hide'事件中,取决于你是否关心这个值。

答案 1 :(得分:1)

如果您想获取所选字段的值,您可以使用此代码。

listeners: {
    change: function(picker,button) {
        selectedValue = picker.getValue()['limit_speed'];
        console.log(selectedValue);
    }
}

答案 2 :(得分:0)

您可以获取动态创建的datepicker

的选定值

听众:{                                     更改:function(picker,selectedValue){                                         的console.log(了selectedValue);                                     }                                 }