JavaScript
  Home arrow JavaScript arrow Page 2 - Using the EXT JS Date Picker Widget
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Using the EXT JS Date Picker Widget
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 10
    2008-07-14

    Table of Contents:
  • Using the EXT JS Date Picker Widget
  • Invoking the Date Picker
  • Finishing the Example
  • Finishing continued

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using the EXT JS Date Picker Widget - Invoking the Date Picker


    (Page 2 of 4 )

    It takes very little code to create a basic implementation of the date picker. Directly after the first two <script> tags, add the following code:

    <script type="text/javascript">

     

    //set local blank image

    Ext.BLANK_IMAGE_URL = 'ext/resources/images/default/s.gif';

     

    //define function to be executed when page loaded

    Ext.onReady(function() {

     

    //create the date picker

    var myDP = new Ext.DatePicker();

     

    //render the date picker

    myDP.render('calendar');

     

    });

    </script>


    The library uses a blank gif image for various things. If we don’t map the BLANK_IMAGE_URL constant to a local resource, the file will be downloaded from EXT, so for performance, it’s best to start every EXT JS script by setting this locally. Next we use the onReady method of the library to specify an anonymous function to be executed when the page has loaded. Using this means that we don’t interact with the DOM until it is in a usable state. Like the blank image property, this is something that you’ll probably use in every EXT JS implementation.

    Next we define the myDP variable, which is used to hold the date picker object. This object is created using the DatePicker method of the library. Once the date picker object has been created, calling the render method adds the date picker to our empty container element and displays it on the page.

    If you run the page in your browser at this point, the date picker will be visible on the page as soon as it loads. You can browse different months and see the elements that are available, like the today button, which automatically selects the current date, for example.

    The DatePicker constructor method also accepts a configuration object, which can be specified inline or passed to the method at instantiation time. There are a range of different configuration properties available (the API browser on the EXT JS documentation page lists them all) and one of them allows us to change the day in the first column of the date picker (Sunday is shown first by default). Change the onReady function so that it appears as follows (new code is shown in bold):

    //define function to be executed when page loaded

    Ext.onReady(function() {


    //create the date picker

    var myDP = new Ext.DatePicker(

    { startDay: 1 }

    };

    The day columns are represented using a zero-based index. To make the widget start on Monday we just supply the index for Monday as the value of the startDay property. There are many other properties that can be used to alter the default implementation of the date picker widget. Any configuration properties like this are passed to the date picker constructor method as a literal object.

    More JavaScript Articles
    More By Dan Wellman


       · I hope this article shows you how powerful Ext-js is and how easy it is to...
       · Dan.. great example. Since many pages have multiple dates/calendars, perhaps you can...
       · found this clean solution at: http://extjs.com/forum/showthread.php?t=20776
       · Good Example in fact it's best example. I searched a lot. I found many but This...
       · Thanks, glad it helped :D
       · i go through this examlpe i tried on the my system. its great . but when after...
     

    JAVASCRIPT ARTICLES

    - Using jQuery to Preload Images with CSS and ...
    - Using Client-Side Scripting to Preload Image...
    - Removing Non-Semantic Markup when Preloading...
    - Using the Display CSS Property to Preload Im...
    - Preloading Images with CSS and JavaScript
    - Scaling and Moving Web Page Elements with th...
    - Fading, Hiding and Sliding HTML Elements wit...
    - Toggling CSS Properties with the GX JavaScri...
    - Cancel, Queue and Pause Animations with the ...
    - Producing Elastic Effects with the GX JavaSc...
    - Moving Divs Diagonally with the GX JavaScrip...
    - Moving Elements Vertically and Horizontally ...
    - Making Bouncing Effects in Parallel with the...
    - Creating Bouncing Effects with the GX JavaSc...
    - Manipulating Background Colors with the GX J...







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek