sencha touch picker

来源:互联网 发布:哪些网游有mac版 编辑:程序博客网 时间:2024/05/03 06:32
                xtype: 'selectfield',
                id: 'duration',
                name: 'duration',
                label: '时长',
                labelWidth: '35%',
                usePicker: true,
                listeners: {
                    'focus' : function(a,e, eOpts) {
                    Ext.getCmp('duration').setOptions('');
                        function pad2(d) {
                            return (d < 10 ? '0' : '') + d;
                        }
                        
                        var hours = [];
                        for (var h = 1; h <= 23; h++) {
                            hours[hours.length] = {
                                text: pad2(h),
                                value: pad2(h)
                            };
                        }
                        
                        var minutes = [];
                        for (var m = 0; m <= 59; m++) {
                            minutes[minutes.length] = {
                                text: pad2(m),
                                value: pad2(m)
                            };
                        }
                        
                        var picker = Ext.create('Ext.Picker', {
                        cancelButton: {
                        text: '取消'
                            },
                            doneButton: {
                            text: '确定'
                            },
                            slots: [{
                                    align: 'center',
                                    name : 'hour',
                                    title: '小时',
                                    data: hours,
                                    flex: 2
                                },{
                                    align: 'center',
                                    name : 'min',
                                    title: '分钟',
                                    data: minutes,
                                    flex: 2
                                }],
                                listeners: {
                                    change: function (picker, newValue, oldValue) {
                                    var optionValue = newValue.hour+':'+newValue.min;
                                        Ext.getCmp('duration').setOptions({text: optionValue,  value: optionValue});
                                    },
                                    cancel: function (picker) {
                                        
                                    }
                                }
                        });
                        Ext.Viewport.add(picker);
                        picker.show();
                    },
                    initialize: function(s, eOpts){
                    Ext.getCmp('duration').setOptions({text: '01:00',  value: '01:00'});
                    }

                }



如果代码是自己看着picker 组件写的,还是有问题的,不够完美,希望以后能完善一下

            
原创粉丝点击