Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ext.ux.form.field.DateTime questions

Tags:

extjs

extjs4

I create a Ext.ux.form.field.DateTime plugin, but here is some questions:

  1. if i don't set width/height, then DateTime in toolbar is missing
  2. cant show correct width in RowEditing plugin

enter image description here

Ext.define('Ext.ux.form.field.DateTime', {
    extend:'Ext.form.FieldContainer',
    mixins: {
        field: 'Ext.form.field.Field'
    },
    alias: 'widget.datetimefield',
    layout: 'hbox',
    width: 200,
    height: 22,
    combineErrors: true,
    msgTarget :'side',

    dateCfg:{},
    timeCfg:{},

    initComponent: function() {
        var me = this;
        me.buildField();
        me.callParent();
        this.dateField = this.down('datefield')
        this.timeField = this.down('timefield')
        me.initField();
    },

    //@private
    buildField: function(){
        this.items = [
            Ext.apply({
                xtype: 'datefield',
                format: 'Y-m-d',
                width: 100
            },this.dateCfg),
            Ext.apply({
                xtype: 'timefield',
                format: 'H:i',
                width: 80
            },this.timeCfg)
        ]
    },

    getValue: function() {
        var value,date = this.dateField.getSubmitValue(),time = this.timeField.getSubmitValue();
        if(date){
            if(time){
                var format = this.getFormat()
                value = Ext.Date.parse(date + ' ' + time,format)
            }else{
                value = this.dateField.getValue()
            }
        }
        return value
    },

    setValue: function(value){
        this.dateField.setValue(value)
        this.timeField.setValue(value)
    },

    getSubmitData: function(){
        var value = this.getValue()
        var format = this.getFormat()
        return value ? Ext.Date.format(value, format) : null;
    },

    getFormat: function(){
        return (this.dateField.submitFormat || this.dateField.format) + " " + (this.timeField.submitFormat || this.timeField.format)
    }
})
like image 479
atian25 Avatar asked May 23 '11 01:05

atian25


1 Answers

You can use flex

        Ext.apply({
            xtype: 'datefield',
            format: 'Y-m-d',
            width: 100,
            flex: 2
        },this.dateCfg),
        Ext.apply({
            xtype: 'timefield',
            format: 'H:i',
            width: 80,
            flex: 1
        },this.timeCfg)
like image 187
Mustafa Murat AYDIN Avatar answered Nov 09 '22 12:11

Mustafa Murat AYDIN