Thursday, December 1, 2011

ClariFit From/To Date Picker Plug-in

In my previous post I discussed an issue about dynamic min and max dates using the APEX date picker. If you haven't read the article please take a few minutes before continuing.

At the end of my previous post I left off with the following question: How do you solve the dynamic min/max date issue? The answer is to use a new plugin that I created called ClariFit From To Date Picker. This is a free and open source plugin created as part of the ClariFit plugin set and is covered in detail in the book: Expert Oracle Application Express Plugins.

The plugin is an item plugin. Its options (shown below) are similar to the APEX date picker. The main difference is that instead of having Minimum and Maximum date attributes you now have Date Type and Corresponding Date Item attributes. The Date Type can either be a From or To date (i.e. min/max date). The Corresponding Date Item is the item name for the date picker that will determine the date's restrictions.


I've created a demo on plugins.clarifit.com. If you select a date in the From Date field (in this case 24-Nov-2011) then open the To Date date picker you'll notice that you can't select anything before 24-Nov-2011 as shown below.


The plugin also comes bundled with some nifty features that may not be visible at first but are really useful:
  • Allows for different From/To date formats (i.e. they don't need to be the same). 
  • Built in validations:
    • Validates that the input is a valid date
    • Validates that From Date is less than or equal to the To Date
  • Javascript Console instrumentation (run the page in debug mode and look at the console)
Note: The built in validations will run as part of the page's validations and are only executed if you enable validation as part of your submit button.

The plugin can be downloaded from apex-plugin.com.

16 comments:

  1. Nice, just what I was looking for. I just hated making these date validations.

    ReplyDelete
  2. Hi Martin,
    I kept getting compatibility errors when trying to install this into APEX XE 4.0.2.00.09. Message reads "NOT COMPATIBLE (Your export may contain calls not supported by your application version.)". Have you any ideas as to why this would be?
    Thanks
    Alan

    ReplyDelete
  3. Hi Alan,

    This plugin was built in APEX 4.1 this the compatibility error. If you need it right away you can port it back to 4.0.

    If time permits, I may release it as a 4.0 plugin in the near future.

    Martin

    ReplyDelete
  4. Sorry Martin I should have realised. Just thought you ought to know that the version on the download page says minimum 4.0.

    Alan

    ReplyDelete
  5. Hi, this is a really useful plug-in for an app I have been developing. I wondered if you had any ideas/plans on how I could do something similar in a tabular form. Basically N rows will be displayed and the start date of a particular field must have a min-date set to the value of the same item on the row above ( the rows always be fixed in their display seq ). At the point save, no date can be earlier than the date on the row before , ie. sequential.
    Thanks

    ReplyDelete
  6. Hi Martin,

    If you take a look at the JS code provided with the plugin you can see what I did to enforce the min max dates and use that for your tabular form. You'll obviously need to modify the code and also add some additional attributes to your tabular form fields.

    Martin

    ReplyDelete
  7. Hi Alan,

    Thanks for pointing it out. Right now an apex-plugin.com the Min Apex Version list does not contain "4.1". I've asked them to include 4.1 so that others don't run into the same issue that you had.

    Martin

    ReplyDelete
  8. Hi Martin,

    Great plugin. Worling fine on Apex 4.1.0.00.32 running on 11G, but can't get it to work under the same Apex release on Oracle XE. I've followed the steps in the book but teh Firebug console gives me the following error on page load
    "$.ui is undefined
    [Break On This Error] {"triggeringElementType":"BUTTON","tri....CLARIFIT.APEXPLUGIN.APEX_DIALOG"}]},
    f?p=10...16::::: (line 115)"

    Any help would be appreciated
    Thanks

    Alan

    ReplyDelete
  9. Martin,

    Apologies, my previous post actually refers to the Clarifit Dialog plugin from you book, not this Datepicker.

    Alan

    ReplyDelete
  10. Hi Alan,

    Can you please post a copy of your application on apex.oracle.com and then give me access to the workspace / application. You can email me the login credentials (my email is in the top right corner of the blog)

    ReplyDelete
  11. Hi Martin,

    I've put the app on apex.oracle.com and emailed you the WS/user details.

    Thanks for looking at this.

    Alan

    ReplyDelete
  12. Hi Martin,

    Able to installed using theme 21 on apex.oracle.com but encountered below error on my site:
    ORA-06550: line 73, column 69: PL/SQL: ORA-00907: missing right parenthesis ORA-06550: line 73, column 7: PL/SQL: SQL Statement ignored.

    Difference noticed in Shared Components/Plug-ins/Edit, the Internal Name and Type are both readonly on apex.oracle.com wherea on my site they are text field and select list respectively.
    When i apply changes, same error.

    Thanks in advance
    Zack

    ReplyDelete
    Replies
    1. Hi,
      i have the same problem and no idea to solve it.

      I hope you have a solution???

      Thanks
      Willy

      Delete
    2. Can you please post on apex.oracle.com and email me a login to the workspace so I can test it out? (My email is in top right corner of blog).

      Thanks,

      Martin

      Delete
  13. Hi Martin,
    Can we still have a mindate and maxdate for each of the dates with the second date's min date being dependent on the date picked in the first date.

    ReplyDelete
  14. Is it possible to make this work using a date and time datepicker?

    Ive been trying for a long time, and I cant make it work yet...

    ReplyDelete