QChangeEvent on a QDateTimeTextbox with linked QCalendar

thread: 6 messages  |  last: a year ago  |  started: wednesday, january 20, 2010, 6:54 pm pst


#1  |  Patrick Ranger (Montreal, Qc) Canada
Wednesday, January 20, 2010, 6:54 PM PST

I select data for a QDataGrid according to a date entered in a QDateTimeTextbox. Whenever the date is changed by a user, I need to refresh the datagrid according to this date. With the old calendar popup I could use a QChangeEvent to refresh the datagrid when a date was chosen, but ever since I switched to a QDateTimeTextbox with linked DHTML QCalendar, the QChangeEvent isn't fired when the date is changed. So I had to add a button, and I hate to see that button. Anyone know how I could refresh the datagrid when a date is chosen in the DHTML QCalendar?

#2  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Wednesday, January 20, 2010, 8:50 PM PST

Patrick... that's def. a good feature request -- but unfortunately QCalendar doesn't support that right now.

If you could, please go ahead and open up a ticket in the issue tracker for this... and better yet, if you're willing to try stuff out, you could look into implementing something like this, as well =)

It would obviously involve editing QCalendar.class.php as well as calendar.js... I'm not too sure, but I would assume that we would want to allow users to add a QChangeEvent action handler to QCalendar... in theory, qcodo would then render out the qcalendar control (which is actually just the IMG tag for the calendar icon) with a “onchange” on it.  If so, then we would just need to add some code in calendar.js to go ahead and execute that “onchange” code in objControl.hideCalendar() in calendar.js

Hope that makes sense... let me know if you have any questions

#3  |  Patrick Ranger (Montreal, Qc) Canada
Thursday, January 21, 2010, 6:31 AM PST

Hmmm... it does make sense, but then we could take a shortcut. Instead of adding events to QCalendar.class.php, we could just fire the onchange event of the QDateTimeTextbox by adding this.dateTimeTextBox.onchange(); to the objControl.setDate function (or objControl.hideCalendar function). I just tried it and seems to work as expected. What do you think?

#4  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Thursday, January 21, 2010, 6:48 AM PST

LOL yeah -- that does make sense... and definitely a lot simpler than my original approach. =)

And yes, it should be setDate, not hideCalendar.

Could you still open up an ticket for this and we'll easily be able to get this in, hopefully in the next rev.

#5  |  Patrick Ranger (Montreal, Qc) Canada
Thursday, January 21, 2010, 7:08 AM PST

Yes I will open a ticket right away. Thanks a lot for your help.

#6  |  w. Patrick Gale (Chapel Hill, NC) United States of America
Friday, February 19, 2010, 12:20 PM PST

Awesome thanks Patrick.  I had to go to the ticket you posted for the details, so for those who need to know before the next code release, just modify the calendar.js file and change the function below:

objControl.setDate = function(intYear, intMonth, intDay) {
            this.dateTimeTextBox.value = qcodo.monthNamesAbbreviated[intMonth] + " " + intDay + " " + intYear;
            this.dateTimeTextBox.onchange();
            this.hideCalendar();
};


Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.