Results 1 to 6 of 6

Thread: Disabling or hiding DatePicker today button [2.0.1]

  1. #1
    Ext User halkon_polako's Avatar
    Join Date
    Nov 2007
    Location
    Barcelona
    Posts
    193

    Default Disabling or hiding DatePicker today button [2.0.1]

    Hi, as an example that how we can disabling and/or hiding the today button, we can use:
    Code:
    Ext.override(Ext.DatePicker,{
      onRenderOriginal: Ext.DatePicker.prototype.onRender,
      onRender: function(container, position){
         this.onRenderOriginal(container,position);
         this.eventEl.addKeyListener(Ext.EventObject.SPACE,Ext.emptyFn,  this);
         this.todayBtn.hide(); //HIDE BUTTON. PUT YOUR LOGIC HERE
      }
    });
    In the case shown, the button is hidden. We can hide it or disable it taking in account the rules that we want, maybe, if today is out from the max/min values setted on DatePicker.
    I let to you to implement the logic , just I show a place.
    Last edited by halkon_polako; 3 Feb 2008 at 12:01 PM. Reason: Version added

  2. #2
    Sencha User
    Join Date
    Apr 2012
    Location
    Austin, Texas
    Posts
    4

    Default

    This is now supported in Ext (for 2.2+). Please see details here.

  3. #3
    Sencha Premium Member
    Join Date
    Sep 2008
    Posts
    11

    Default

    I am still using 2.0.1, so I can't use the new showToday config in 2.2. I tried using this example, but it does not work, because todayBtn is not a variable defined in the DatePicker class. It is a local variable inside of the original onRender (which becomes onRenderOriginal) so it is out of scope in the overridden onRender.

  4. #4
    Ext User halkon_polako's Avatar
    Join Date
    Nov 2007
    Location
    Barcelona
    Posts
    193

    Default

    Hi... since todayBtn is a variable 'autodefined' in the DatePicker class, I mean, that it is not defined explicitely.
    It is defined by an assignament inside the onRender method (as you can see... this.todayBtn=....), so if in your override onRender you first call onRenderOriginal method, the variable todayBtn becomes created and available.

  5. #5
    Sencha Premium Member
    Join Date
    Sep 2008
    Posts
    11

    Default

    Maybe I have a slightly different version of Ext? This is what I see in the original DatePicker onRender:


    Code:
     
    var today = (new Date()).dateFormat(this.format);
    var todayBtn = new Ext.Button({
        renderTo: this.el.child("td.x-date-bottom", true),
        text: String.format(this.todayText, today),
        tooltip: String.format(this.todayTip, today),
        handler: this.selectToday,
        scope: this
    });
    It does not assign to this.todayBtn. Later when I try to access this.todayBtn my browser gives me an error. I was told that we are using version 2.0.1 here at work, though the top line only says
    Ext JS Library 2.0
    Last edited by DannyMeister; 31 Oct 2008 at 6:52 AM. Reason: Wrap code in [code] tag

  6. #6
    Ext User halkon_polako's Avatar
    Join Date
    Nov 2007
    Location
    Barcelona
    Posts
    193

    Default

    Well... I just downloaded Ext2.0.1 to verify this, and this is the code inside DatePicker:

    Code:
     var today = (new Date()).dateFormat(this.format);
            this.todayBtn = new Ext.Button({
                renderTo: this.el.child("td.x-date-bottom", true),
                text: String.format(this.todayText, today),
                tooltip: String.format(this.todayTip, today),
                handler: this.selectToday,
                scope: this
            });
    So... I think you are not using 2.0.1.
    If the top line of your source says Ext 2.0, then you are using Ext 2.0 not 2.0.1, so this patch can't be work.
    Try to go the the latest version 2.2 or 2.0.2 or override the full original onRender() method ...

Posting Permissions

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