1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    7
    Vote Rating
    0
    leela 7 is on a distinguished road

      0  

    Default Unanswered: display the time picker value in the textfield using sencha touch2

    Unanswered: display the time picker value in the textfield using sencha touch2


    Hi,I created a form ,containing date,time as a fields,I want to display the time picker value in the textfield by using sencha touch2 .my code is

    Ext.define("Datetimepicker.view.Main", {
    extend: 'Ext.form.Panel',
    requires: [
    'Ext.TitleBar',
    'Ext.field.DatePicker',
    'Ext.Spacer',
    'Ext.Picker'
    ],
    config: {
    fullscreen:'true',
    title:'DatatimePicker',


    items: [
    {
    xtype:'fieldset',
    items:[
    {
    xtype:'datepickerfield',
    label:'Birthday',
    picker:{
    minHours:9,
    maxHours:18,
    yearFrom:1980,
    yearTo:2015
    },
    name:'birthday',
    value:new Date()
    },
    {
    xtype:'textfield',
    label:'Time',
    value:new Date(),
    name:'time',
    /* picker:{
    minHours:9,
    maxHours:18
    }*/
    }
    ]
    },
    {
    xtype:'toolbar',
    docked:'bottom',
    items:[
    {
    xtype:'spacer'
    },
    {
    text: 'setValue',
    handler: function() {
    var datePickerField = Ext.ComponentQuery.query('datepickerfield')[0];


    var randomNumber = function(from, to) {
    return Math.floor(Math.random() * (to - from + 1) + from);
    };


    datePickerField.setValue({
    month: randomNumber(0, 11),
    day : randomNumber(0, 28),
    year : randomNumber(1980, 2015)
    });
    }
    },
    { xtype:'spacer'}
    ]
    }
    ]
    }
    });



    by using above code im getting the datepicker,i selected the date from the picker,
    im getting the date successfully in the textfield.in the same way i want to display the time picker,
    when we select the time from that picker ,i want to get that time in the textfield by using sencha touch2,
    can anyone help me to do this ...thanks in advance

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    497
    Answers
    25
    Vote Rating
    51
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    It's really tough to read your code like that which means that people who might be able to help you (perhaps even me!) won't put the extra time in to work out what you're doing atm.

    I think this forum has some BB code you can use - see the options on right hand side of second row in the WYSIWYG editor.

  3. #3
    Sencha User
    Join Date
    Jan 2013
    Posts
    7
    Vote Rating
    0
    leela 7 is on a distinguished road

      0  

    Default


    actually ,I'm new to sencha touch,i want to display the time picker value in the textfield (like date)

  4. #4
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    497
    Answers
    25
    Vote Rating
    51
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    I appreciate that. I'm just saying, if you want help, embed the code inside [ code] tags (without the space). At the moment it's really difficult to read.

  5. #5
    Sencha User
    Join Date
    Jan 2013
    Posts
    7
    Vote Rating
    0
    leela 7 is on a distinguished road

      0  

    Default


    shepsii,im trying to embed the code ,but it shows in paragraph,can you help me

  6. #6
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    497
    Answers
    25
    Vote Rating
    51
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    Code:
    Ext.define("Datetimepicker.view.Main", {
      extend: 'Ext.form.Panel',
      requires: [
        'Ext.TitleBar',
        'Ext.field.DatePicker',
        'Ext.Spacer',
        'Ext.Picker'
      ],
      config: {
        fullscreen:'true',
        title:'DatatimePicker',
    
    
    
    
      items: [
      {
        xtype:'fieldset',
        items:[
        {
          xtype:'datepickerfield',
          label:'Birthday',
          picker:{
            minHours:9,
            maxHours:18,
            yearFrom:1980,
            yearTo:2015
          },
          name:'birthday',
          value:new Date()
        },
        {
          xtype:'textfield',
          label:'Time',
          value:new Date(),
          name:'time',
          /* picker:{
          minHours:9,
          maxHours:18
          }*/
        }
        ]
      },
      {
        xtype:'toolbar',
        docked:'bottom',
        items:[
        {
          xtype:'spacer'
        },
        {
          text: 'setValue',
          handler: function() {
            var datePickerField = Ext.ComponentQuery.query('datepickerfield')[0];
    
    
    
    
            var randomNumber = function(from, to) {
              return Math.floor(Math.random() * (to - from + 1) + from);
            };
    
    
    
    
            datePickerField.setValue({
            month: randomNumber(0, 11),
            day : randomNumber(0, 28),
            year : randomNumber(1980, 2015)
            });
          }
        },
        { xtype:'spacer'}
        ]
        }
      ]
      }
    });

  7. #7
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    497
    Answers
    25
    Vote Rating
    51
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    Right so what you have here is a sencha touch view.

    You need to look into the MVC aspects of Sencha Touch and use a controller for the kind of logic you are trying to do.

    I'd recommend going to the Sencha Touch docs and spend a good day or so reading through them and looking at some of the MVC examples that come with the sencha touch download; if in the app folder they also have controller view model etc folders, that's an MVC app.

    Also auto-generating a new app from Sencha Cmd gives you this structure.

    Sorry I'm not more specific at this stage - I would need to actually go ahead and write a controller class for you to probably help much more! And it's better if you take a look at some other examples and go from there.

  8. #8
    Sencha User
    Join Date
    Jan 2013
    Posts
    7
    Vote Rating
    0
    leela 7 is on a distinguished road

      0  

    Default


    actually i tried some other code ,but im failed.whatever it may be thanks for quick reply

  9. #9
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    497
    Answers
    25
    Vote Rating
    51
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    Ok, generally I think you're probably at the stage where you need to learn how the framework works in more general terms rather than getting into a specific coding task at this stage. If you're looking to do this without MVC, I'll step aside and let someone else lend you a hand because all the apps I've done have used MVC. Sencha Touch just works better that way...

Thread Participants: 1

Tags for this Thread