JavaScript
  Home arrow JavaScript arrow Page 4 - 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 
Sun Developer Network 
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: 4 stars4 stars4 stars4 stars4 stars / 3
    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 - Finishing continued


    (Page 4 of 4 )

    We can add a listener for this event very easily by specifying it in the configuration object passed to the date picker constructor. Change the constructor so that it appears as follows (new code is again shown in bold):

    //create the date picker

    var myDP = new Ext.DatePicker(

    {

    startDay: 1,

    listeners: {

    'select':selectHandler

    }

    }

    );

    The listeners property accepts an object literal listing the event to listen for as a property key and the handler function as the property value. Try the code out now; it should do everything that we set out to achieve. For reference, the complete file should now appear as follows:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

    <html>

    <head>

    <link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title>EXT JS Datepicker Example</title>

    </head>

    <body>

    <label>Enter a date: </label><input type="text" id="dateField"><button id="openCalendar">Open Calendar</button><div id="calendar"></div>

    <script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script>

    <script type="text/javascript" src="ext/ext-all.js"></script>

    <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() {

     

    //define select handler

    var selectHandler = function(myDP, date) {

     

    //get the text field

    var field = document.getElementById('dateField');

     

    //add the selected date to the field

    field.value = date.format('d/m/Y');

     

    //hide the date picker

    myDP.hide();

     

    };

     

    //create the date picker

    var myDP = new Ext.DatePicker(

    {

    startDay: 1,

    listeners: {

    'select':selectHandler

    }

    }

    );

     

    //render the date picker

    myDP.render('calendar');

     

    //hide date picker straight away

    myDP.hide();

     

    //define click handler

    var clickHandler = function() {

     

    //show the date picker

    myDP.show();

     

    };

     

    //add listener for button click

    Ext.EventManager.on('openCalendar', 'click', clickHandler);

     

    });

    </script>

    </body>

    </html>

    Summary

    Using the widgets and other classes provided by EXT JS is easy and intuitive, and can help you to quickly and easily create robust and attractive interfaces. The widgets are styled to a professional degree and work exactly as the API describes.

    -DOWNLOAD SOURCE-


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · I hope this article shows you how powerful Ext-js is and how easy it is to...
     

    JAVASCRIPT ARTICLES

    - More on JavaScript Array Objects
    - Methods of the DOM Location Object
    - The DOM Location Object Properties
    - Handling Remote Files with JavaScript Click ...
    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...


     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT