Page 1 of 5 123 ... LastLast
Results 1 to 10 of 45

Thread: [3.x] Ext.ux.grid.AutoRefresher

  1. #1
    Sencha User galdaka's Avatar
    Join Date
    Mar 2007
    Location
    Spain
    Posts
    1,164

    Default [3.x] Ext.ux.grid.AutoRefresher

    28/04/2009: First version.
    29/04/2009: Rewrite. Felixibilize the plugin and support locale.
    30/04/2009: New version. countdownClock and more changes.
    30/04/2009: Capture http://www.jadacosta.es/contents/scr...t/capture1.swf
    02/06/2009: Minor change for last rev of ExtJS 3.0
    13/06/2009: Remember datastore last options.
    14/06/2009: Changed applying locale. Thanks jay garcia!!
    15/06/2009: Added GNU License.
    11/08/2009: Fixed some bugs. Added price: 18. In a pack with PageSizer is offered for 30. Contact to: [email protected]
    03/11/2009: License changed. Reason: People use your work for comercial purposes without your permission.
    03/11/2009: NEW LICENSE: http://creativecommons.org/licenses/by-nc/3.0/. Thanks to cparker.


    PHP Code:
     
    /**
     * Ext.ux.grid.AutoRefresher 
     * Copyright (c) 2009-2010, Jos Alfonso Dacosta Dominguez ([email protected])
     *
     * Ext.ux.grid.AutoRefresher is licensed http://creativecommons.org/licenses/by-nc/3.0/ license.
     *
     * Commercial use is prohibited. contact with [email protected]
     * if you need to obtain a commercial license.
     *
     *  Site: www.jadacosta.es
     */
     
    Ext.namespace('Ext.ux.grid');
    Ext.ux.grid.AutoRefresher Ext.extend(Ext.CycleButton, {
     
    withoutTimeText' Núnca',
     
    secondsText' segundo(s)',
     
    minutesText' minuto(s)',
     
    hoursText' hora(s)',
     
    refreshText' Refresco en: ',
     
    countdownClocktrue,
     
    runnernull,
     
    clockTask null,
     
    counter0,
     
    refresherTimesthis.refresherTimes || [{text''value0checkedtruetimeTextType'n'checkedtrue},
      {
    text' 5'value5timeTextType's'},
      {
    text' 10'value10timeTextType's'},
      {
    text' 30'value30timeTextType's'},
      {
    text' 1'value1timeTextType'm'},
      {
    text' 5'value5timeTextType'm'},
      {
    text' 10'value10timeTextType'm'},
      {
    text' 15'value15timeTextType'm'},
      {
    text' 30'value30timeTextType'm'},
      {
    text' 1'value1timeTextType'h'}
     ],
     
    initComponent: function(){
      var 
    rt=[];
      var 
    wt this.withoutTimeText;
      var 
    st this.secondsText;
      var 
    mt this.minutesText;
      var 
    ht this.hoursText;
      
    Ext.each(this.refresherTimes, function(r){rt.push({
       
    textr.timeTextType == 'n' r.text wt r.timeTextType == 'h' r.text ht r.timeTextType =='s' r.text st r.text mt,
       
    valuer.timeTextType == 'n' r.timeTextType == 'h' r.value*3600 r.timeTextType =='s' r.value r.value*60,
       
    checkedr.checked true false
      
    })
     });
     
     
    Ext.apply(this, {
      
    showTexttrue,
      
    prependText' ',
      
    forceIconExt.ux.iconMgr.getIcon('/dev/common/icons.nsf/extjs/ux/icons/''clock_refresh'),
      
    itemsrt
     
    });
     
    Ext.ux.grid.PageSizer.superclass.initComponent.apply(thisarguments);
    },
    init: function(pagingToolbar) {
     var 
    cycleButton this;
     
    this.pagingToolbar pagingToolbar
     if (
    pagingToolbar.store) {this.store pagingToolbar.store
     
    pagingToolbar.on('render'this.onInitViewthis);
     
    pagingToolbar.on('beforechange'this.onInitCounterthis);
     
     
    this.store.startAutoRefresh = function(interval){ 
      if(
    this.autoRefreshProcId){ 
       
    clearInterval(this.autoRefreshProcId); 
      } 
      
    //var opt = this.lastOptions.params;
      //this.autoRefreshProcId = setInterval(this.reload.createDelegate(this, [{params: opt}]), interval*1000); 
      //var opt = this.lastOptions.params;
      
    this.autoRefreshProcId setInterval(this.reload.createDelegate(this), interval*1000); 
      if(
    cycleButton.countdownClock){
       
    this.on('load', function(){
        
    cycleButton.clockTask.counter cycleButton.getActiveItem().value;
       });
      }
     } 
     
    this.store.stopAutoRefresh = function(){ 
      if(
    this.autoRefreshProcId){ 
       
    clearInterval(this.autoRefreshProcId); 
      } 
     } 
    },
    onInitView: function(pagingToolbar){
     
    pagingToolbar.insert(12this);
     
    pagingToolbar.insert(12'-');
     
    this.on('change'this.onTimeRefreshChangedpagingToolbar);
     
    this.fireEvent('change'this);
    },
    onInitCounter: function(pagingToolbar){
     
    this.fireEvent('change'this);
    },
    createRunner: function(cycleButtonvalue){
     
    this.runner == null this.runner = new Ext.util.TaskRunner() : this.runner.stopAll(this.clockTask); 
     
    this.clockTask = {
      
    countervalue,
      
    run: function(){
       
    this.counter this.counter-1;
       
    this.counter>=true this.counter 0
       
    var hours '0' Math.floor(this.counter/60
       
    hours hours.substr(hours.length-2hours.length)
       var 
    minutes '0' this.counter%60;
       
    minutes minutes.substr(minutes.length-2minutes.length)
       
    Ext.getCmp(cycleButton.id).el.child("td.x-btn-mc " Ext.getCmp(cycleButton.id).buttonSelector).update(cycleButton.refreshText hours ':' minutes)
      },
      
    interval1000
     
    };
    },
    onTimeRefreshChanged: function(cycleButton){
     var 
    value cycleButton.getActiveItem().value
     if(
    cycleButton.countdownClockcycleButton.createRunner(cycleButtonvalue);
     if (
    value 0){ 
      if(
    cycleButton.countdownClockcycleButton.runner.start(cycleButton.clockTask);
      
    this.store.startAutoRefresh(value); 
     }else{ 
      if(
    cycleButton.countdownClockcycleButton.runner.stopAll(cycleButton.clockTask);
       
    this.store.stopAutoRefresh(); 
      } 
     }
    });
    if(
    Ext.ux.grid.AutoRefresher){
     
    Ext.override(Ext.ux.grid.AutoRefresher, {
      
    withoutTimeText " Núnca",
      
    secondsText " segundo(s)",
      
    minutesText " minuto(s)",
      
    hoursText " hora(s)",
      
    refreshText " Refresco en: "
     
    });

    View also Ext.ux.grid.PageSizer: http://extjs.com/forum/showthread.php?t=66954
    Attached Images Attached Images

  2. #2
    Sencha User galdaka's Avatar
    Join Date
    Mar 2007
    Location
    Spain
    Posts
    1,164

    Default

    I rewrite entire plugin for make it more flexible.

    1) Now support locale.

    2) Two config options:

    initialTime: You can define the initial auto-refresh period time.
    refresherTimes: You can define de posible refresher times.

    Greetings,

  3. #3
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    Hi Galdaka, you might want to start using Ext.plugins instead of Ext.ux if you are developing plugins

  4. #4
    Sencha User galdaka's Avatar
    Join Date
    Mar 2007
    Location
    Spain
    Posts
    1,164

    Default

    Quote Originally Posted by [email protected] View Post
    Hi Galdaka, you might want to start using Ext.plugins instead of Ext.ux if you are developing plugins
    Hey thanks!!

    Which are the changes? Only namespace?

    Greetings,

  5. #5
    Sencha User mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,232

    Default

    Quote Originally Posted by galdaka View Post
    Hey thanks!!

    Which are the changes? Only namespace?

    Greetings,
    yep. it's purely a namespace change. but does wonders for clarity.

  6. #6
    Sencha User galdaka's Avatar
    Join Date
    Mar 2007
    Location
    Spain
    Posts
    1,164

    Default

    Hi,

    I introduce countdownClock option and other improvements.

    Greetings,

  7. #7
    Sencha User galdaka's Avatar
    Join Date
    Mar 2007
    Location
    Spain
    Posts
    1,164

    Default

    Hi people,

    View first post.

    Added capture of funtionallity: http://www.jadacosta.es/contents/scr...t/capture1.swf

    Greetings,

  8. #8

  9. #9
    Sencha Premium Member
    Join Date
    Jun 2008
    Posts
    380

    Default

    Nice! Can be very handy for apps with realtime-data handling!
    I`m from Holland!

  10. #10
    Sencha User
    Join Date
    Nov 2007
    Posts
    294

    Default

    Hi,
    This looks really nice. Is there an example of how to apply it to my grid? I tried instantiating the class and adding it to my plugins list but didn't work that way.

    thanks

Page 1 of 5 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •