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)
The plugin can be downloaded from apex-plugin.com.
Nice, just what I was looking for. I just hated making these date validations.
ReplyDeleteHi Martin,
ReplyDeleteI 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
Hi Alan,
ReplyDeleteThis 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
Sorry Martin I should have realised. Just thought you ought to know that the version on the download page says minimum 4.0.
ReplyDeleteAlan
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.
ReplyDeleteThanks
Hi Martin,
ReplyDeleteIf 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
Hi Alan,
ReplyDeleteThanks 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
Hi Martin,
ReplyDeleteGreat 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
Martin,
ReplyDeleteApologies, my previous post actually refers to the Clarifit Dialog plugin from you book, not this Datepicker.
Alan
Hi Alan,
ReplyDeleteCan 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)
Hi Martin,
ReplyDeleteI've put the app on apex.oracle.com and emailed you the WS/user details.
Thanks for looking at this.
Alan
Hi Martin,
ReplyDeleteAble 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
Hi,
Deletei have the same problem and no idea to solve it.
I hope you have a solution???
Thanks
Willy
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).
DeleteThanks,
Martin
Hi Martin,
ReplyDeleteCan 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.
Is it possible to make this work using a date and time datepicker?
ReplyDeleteIve been trying for a long time, and I cant make it work yet...
Thank you for this plug-in. I spent a day trying to achieve the same result using the standard Apex tools and got nowhere - you're a star!
ReplyDelete