EasyUI Forum
April 29, 2024, 11:45:26 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Datebox to only show the calendar when the user clicks the calendar icon  (Read 9030 times)
morib
Newbie
*
Posts: 14


View Profile
« on: May 09, 2014, 02:20:57 PM »

Hi, I need the datebox to NOT show the calendar when a user types in the text field but only when the user clicks on the calendar icon. The user should be able to type in the text field.

What is the way to implement this ?

Thanks!
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: May 09, 2014, 06:07:34 PM »

To prevent from displaying the calendar panel when press something on input box, override the 'keyHandler'.
Code:
$('#dd').datebox(...).datebox('options').keyHandler.query = function(){
$(this).datebox('hidePanel');
};
Logged
morib
Newbie
*
Posts: 14


View Profile
« Reply #2 on: May 12, 2014, 08:18:14 AM »

Perfect, thanks for the hint !

Here is the final code fragment:

        $('#periodStartDate').datebox('options').keyHandler.query = function () {
            $(this).datebox('hidePanel');
        };
Logged
morib
Newbie
*
Posts: 14


View Profile
« Reply #3 on: May 12, 2014, 09:16:24 AM »

The above solution works for when the user clicks the text part of the datebox.  However, when the user types-in the text part of the datebox the calendar part still pops-up...

I tried to override the other keys but the calendar still pops-up...

        $('#periodStartDate').datebox('options').keyHandler.query = function () {
            $(this).datebox('hidePanel');
        };
        $('#periodStartDate').datebox('options').keyHandler.up = function () {
            $(this).datebox('hidePanel');
        };
        $('#periodStartDate').datebox('options').keyHandler.down = function () {
            $(this).datebox('hidePanel');
        };
        $('#periodStartDate').datebox('options').keyHandler.left = function () {
            $(this).datebox('hidePanel');
        };
        $('#periodStartDate').datebox('options').keyHandler.right = function () {
            $(this).datebox('hidePanel');
        };
        $('#periodStartDate').datebox('options').keyHandler.enter = function () {
            $(this).datebox('hidePanel');
        };

What I need is for the calendar to never show unless the user click on the icon.  How can I override all events on the text part of the databox ?

Thank you for your assistance.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #4 on: May 12, 2014, 04:57:05 PM »

Please refer to this example http://jsfiddle.net/kV679/
Logged
morib
Newbie
*
Posts: 14


View Profile
« Reply #5 on: May 13, 2014, 03:46:39 PM »

That is great, thanks !

What I added is on click of the calendar icon, I set the current date of the Calendar to the selected data from the text data (after performing a conversion on the input text).

            onShowPanel: function () {
                var date = GetDateFromEntry($('#periodStartDate').combobox('getValue'));
                var c = $('#periodStartDate').datebox('calendar');
                c.calendar('moveTo', Date.parse(date));
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!