The Way Of Life: Update Time in ExtJS
Google

Sunday, August 25, 2013

Update Time in ExtJS


If you want to show current time on your ExtJS app, this code may help you. In JS/ ExtJS will displayed local time, that's mean if your computer clock goes wrong, ExtJS will displayed wrong time. This code is written using ExtJS version 4.2.1, if you using newer version and there is new syntax revision, you must making some adjustment to run this code.

 Ext.onReady(function() {
  
    var filterPanel = Ext.create('Ext.panel.Panel', {
    bodyPadding: 5,
    width: 200,
    title: 'Update Time in ExtJS',
    items: [{
        fieldLabel: 'Time',
        id: 'txtTime',
        name: 'txtTime',
        xtype: 'textfield'
      }
    ],
    renderTo: Ext.getBody()
 });

     Ext.TaskManager.start({
        run: function() {
            Ext.getCmp('txtTime').setValue(Ext.Date.format(new Date(), 'H:i:s'));
        },
        interval: 1000
    });

});


This code will show update time until second, you can change the format 'H:i:s' to 'H:i', if you want show time until minute only.Have fun!

related links: Update time in ExtJS automatically

tools : ExtJS ver 4.2.1Notepad++, CodeIgniter, Mozilla FireFox, FireBug

Labels: , ,

0 Comments:

Post a Comment

<< Home