Ask a Question related to Coldfusion Flash Integration, Design and Development.
-
gyannuzzi #1
changing dateField selectedDate
Hello, I have a cfform with actionscript.
Basically I have a data grid that when a row is selected, a cfform is
populated.
The problem is with the datefield.
The datefield text updates without problem, however, the datefield
selectedDate is never updated.
I tried changing the selectedDate property of the datefield, but I received
errors.
In my attempt, the word new was not allowed, when I tried to set the
datefield.selectedDate to a new Date().
Perhaps there are other ways?
gyannuzzi Guest
-
qs. about datefield
hi, I am using datefield in my form. I can choose the date from the calendar without any problem. But if I want to delete the date from the... -
Setting selectedDate in DateChooser?
Is there any way to set the selectedDate in DateChooser to the value that the mouse is pointing to ? instead of the value that the mouse click? ... -
DateField
Hey,Does anyone here knows about how to populate <mx:DataField> with dataprovider data coming from http service from a jsp file (generated XML )... -
Adding one day to .selectedDate Value
how can i add one day to the selected date of a datefield cfinput??? -
Setting SelectedDate in <asp:calendar
I'm trying to set the SelectedDate on an <asp:calendar tag to show the existing value of a date in a field retrieved from a database and put into... -
mjb14 #2
Re: changing dateField selectedDate
I have had the same problem....where I update the value of the date field, but when clicking on the calendar icon, the selected date is not set to the correct value...
mjb14 Guest
-
gyannuzzi #3
Re: changing dateField selectedDate
Any ideas here? Any help from adobe/macromedia? This problem severely limits the utility of the datefield control if there is no workaround.
gyannuzzi Guest
-
BKBK #4
Re: changing dateField selectedDate
selectedDate is not an attribute of datefield. A simple date
field like
<cfform action="test.cfm" method="post" <!--- format="flash" --->>
<cfinput type="datefield" name="start_date">
<cfinput type="submit" name="sbmt" value="send date" >
</cfform>
should work, with or without flash format. Were you perhaps thinking of
cfcalendar?
BKBK Guest
-
gyannuzzi #5
Re: changing dateField selectedDate
Thanks for the response. I am using a cfinput type datefield within a flash
type form as in your code snip.
I thought I might be able to use 'selectedDate' as it is a property of the
Flash datefield object.
But, I will use any way I can to update the selected date of the datefield.
Changing the text only changes the text. When the datefield is clicked by
users, the calendar chooser pops up with the (old date) selected.
gyannuzzi Guest
-
BKBK #6
Re: changing dateField selectedDate
I thought I might be able to use 'selectedDate' as it is a property of the
Flash
datefield object.
In cfform, 'selectedDate' is an attribute of the cfcalendar element, not of a
datefield input element. Even when the format is flash.
Changing the text only changes the text. When the datefield is clicked by
users,
the calendar chooser pops up with the (old date) selected.
This scenario confuses me. It should not be possible for you to change
the text manually. You should only be able to do so by clicking on a date in
the calendar. The selected date then appears in the text field next to the
calendar. Coldfusion highlights the selected date on the calendar with a
colour. Clicking on the text field itself, for whatever reason, should not
enable you to enter anything. It should only result in toggling the calendar
display on or off. That is the functionality as I understand it.
BKBK Guest
-
gyannuzzi #7
Re: changing dateField selectedDate
I have put together a sample bit of code so that everyone can see the problem.
The code produces a simple grid, and a few form fields bound to that grid.
Note that though the datefield text is properly updated when a grid selection
is made, however, the selected date of the datefield is never updated. (what I
mean is, that when you click on the calendar icon, and it pops up the calendar,
the selected date in that calendar does not match the text in your datefield
cfinput)
----------------
<cfset cities = "Rome,Athens,Canberra,Brasilia,Paris">
<cfset countries = "Italy,Greece,Australia,Brazil,France">
<cfset dates = "11/21/2006,2/3/2007,4/14/2007,9/23/2007,11/11/2007">
<cfform name="cities" format="flash">
<cfgrid name="geoGrid" autowidth="yes" height = "120" rowheaders="no">
<cfgridcolumn name="city" header="City">
<cfgridcolumn name="country" header="Country">
<cfgridcolumn name="travelDate" header="Travel Date">
<cfloop index="i" from="1" to="#ListLen(cities)#">
<cfgridrow data ="#ListGetAt(cities, i)#,#ListGetAt(countries, i)#,
#ListGetAt(dates, i)#">
</cfloop>
</cfgrid><br /><br />
<cfinput name="city2" type="text" label="City" width="100"
bind="{geoGrid.selectedItem.city}" />
<cfinput name="country2" type="text" label="Country" width="100"
bind="{geoGrid.selectedItem.country}" />
<cfinput name="travelDate2" type="datefield" label="Travel Date" width="100"
bind="{geoGrid.selectedItem.travelDate}" />
</cfform>
----------------
gyannuzzi Guest
-
BKBK #8
Re: changing dateField selectedDate
> when you click on the calendar icon, and it pops up the calendar, the
cfinput> selected date in that calendar does not match the text in your datefield
That is the expected behaviour. The bind attributes simply inserts the
date from the grid into the travelDate2's text field. The attribute that would
insert the date into the text field as well as on the calendar is value.
BKBK Guest
-
gyannuzzi #9
Re: changing dateField selectedDate
Can you show me the syntax for setting the value in the context of the code I
posted? This is precisely what I have been struggling with. If it is just my
ignorance of the proper syntax, then I would be happy :D
gyannuzzi Guest
-
BKBK #10
Re: changing dateField selectedDate
Gyannuzzi,
I am still looking into the problem. I'm finding it quite tricky. In the
meantime, here are some ideas that may inspire you or someone else.
The most straightforward way is to place the date dynamically into the
datefield's value attribute, thus, value="#selected_travel_date#". But
then, we hit a snag immediately. The value attribute is not an event.
So, its value can be evaluated from a Coldfusion variable, but not from an
Actionscript variable. Yet the value is readily available to us, in
Actionscript, not in Coldfusion.
I have not considered any solution in Coldfusion or in client-side script. I
have the feeling it would be messy. I thought adding/modifying the following
lines would do it
<cfgrid name="geoGrid" autowidth="yes" height = "120" rowheaders="no"
onchange="onGridSelect();">
<cfformitem type="script">
function onGridSelect(){
travelDate2.selectedDate=geoGrid.selectedItem.trav elDate;
}
</cfformitem>
<cfinput name="travelDate2" type="datefield" label="Travel Date" width="100" />
But it doesn't seem to help. I only get what you already got with bind.
I think the calendar doesn't respond because
geoGrid.selectedItem.travelDate is a string. Actionscript alternatives
like
cities.traveldate2=geoGrid.selectedItem.travelDate ;
also fall short for the same reason. Coldfusion apparently expects a Date
object there. However, we cannot get a Date object because the Coldfusion Flash
compiler forbids the use of the keyword "new" in a script.
I came tantalizingly close, using the
[url]http://livedocs.adobe.com/flash/mx2004/main_7_2/00002381.html[/url].
function gridSelect(){
travelDate2.setFocus();
// travelDate2.showToday=False;
// alert('day: '+geoGrid.selectedItem.travelDate.split("/")[1]+', but how to
enter day number in calendar?');
travelDate2.displayedMonth=geoGrid.selectedItem.tr avelDate.split("/")[0]-1;
travelDate2.displayedYear=geoGrid.selectedItem.tra velDate.split("/")[2];
}
<cfinput name="travelDate2" type="datefield"
bind="{geoGrid.selectedItem.travelDate}" label="Travel Date" width="100" />
I could get everything to display, except the day. There is a
displayedMonth and a displayedYear property, but, alas, no
displayedDay. Anyone with a flash?
BKBK Guest
-
gyannuzzi #11
Re: changing dateField selectedDate
Thanks for perservering with this issue. I have something very similar that is
partially working. Perhaps we can yet find a workaround. I have attached the
code. Unfortunately, this code only seems to work once the datefield has had
its date selected manually by the user one time. Once the user has done that,
it works. I have tried variations (including the removal of my conditional),
but to no avail. I thought your setFocus might do the trick, but it didnt seem
to help. Anyways, here is what I have, maybe it brings us a step closer.
<!--- helper function to update selectedDate for a datefield control
Note: FLAWED but better than nothing, this only selects date once user has
selected date one time.
--->
public function update_datefield_selectedDate(df:mx.controls.DateF ield,
date_as_string:String):Void {
var date_as_array:Array;
var new_date:Date;
new_date = df.selectedDate;
if (new_date != undefined) {
date_as_array = date_as_string.split("/");
/* set full year(year, month (0-11), date) */
new_date.setFullYear(date_as_array[2], date_as_array[0]-1,
date_as_array[1]);
df.selectedDate = new_date;
}
return;
}
gyannuzzi Guest
-
BKBK #12
Re: changing dateField selectedDate
I can still not find the code to dynamically prick a date in the datefield
calendar. The selectedDate property is no use, as it exists only after
you select a date. We've gone as far as we can. Let's ask
[url]http://www.asfusion.com/blog/archives/category/cfform[/url].
BKBK Guest
-
Chuck1411 #13
Re: changing dateField selectedDate
I have this working, you just have to have a hidden field in the grid that is a
date object of that date. Then, thx to your post above I do in action script
in the onChange event in the grid, I set the values like this...
DateOfArrival.text = grid.selectedItem.Date_string;
DateOfArrival.selectedDate = grid.selectedItem.Date;
Then I only have the Date_string show in the grid with the <cfgridcolumn> tag.
Because having Date was unsortable (cause it had names for the months, and it
has a bug, because I use times, and if I set the time to 2300, it displays the
next day in the grid even tho the date in the db is correct. Shrug, that's
another issue, but anyway the above works for me.
My date string has the format MM/DD/YYYY, though I think YYYY/MM/DD would be
better on sorting, its less readable. I'm still new enough, if you have a
better idea on sorting, maybe convert the date to a number (its prolly a number
anyway, though I don't know how to use it that way) and sort it with that.
Chuck1411 Guest
-
BKBK #14
Re: changing dateField selectedDate
I cannot figure out what you mean. Could you please say it again using the code in my posting of April 30?
BKBK Guest
-
Chuck1411 #15
Re: changing dateField selectedDate
[q]Originally posted by: BKBK
<cfgrid name="geoGrid" autowidth="yes" height = "120" rowheaders="no"
onchange="onGridSelect();">
<cfformitem type="script">
function onGridSelect(){
travelDate2.selectedDate=geoGrid.selectedItem.trav elDate;
}
</cfformitem>
<cfinput name="travelDate2" type="datefield" label="Travel Date" width="100" />
cities.traveldate2=geoGrid.selectedItem.travelDate ;
<cfinput name="travelDate2" type="datefield"
bind="{geoGrid.selectedItem.travelDate}" label="Travel Date" width="100" />
[/q]
If travelDate is a Date object, then add to your table/schema
travelDate_string, and use DateFormat(Date,"MM/DD/YYYY") when ever you
insert/update the table/schema to put the string in it. I'm sure that is
obvious enough, so I won't post that code.
Then within...
<cfgrid name="geoGrid" autowidth="yes" height = "120" rowheaders="no"
onchange="onGridSelect();">
I have it populated with a query() of basically select * from table which
includes both date fields, the date object and the date_string which I manually
create on insert/update via dateFormat mentioned above.
BUT, beneathe the <cfgrid> tag I have my...
<cfgridcolumn name="travelDate_string" header="Date" />
and I do not have a <cfgridcolumn showing the date object, so I have the date
object as a 'hidden' column within the grid, but the values are there for each
row. So when
onGridSelect(){
travelDate2.selectedDate=geoGrid.selectedItem.trav elDate;
add also
travelDate2.text = geoGrid.selectedItem.travelDate_string;
}
and wallah, it works.
I used default of travelDate being an object of Date, but if you have
travelDate as a string, add to your table/schema a datefield, and on your
insert/create statements use createDate(). Then using the above code, I
believe it should work for you.
The working application is: tracker.searisen.com (Login as Guest to work with
the demo).
Chuck1411 Guest
-
-
BKBK #17
Re: changing dateField selectedDate
The code you suggest doesn't work. At least, not when one implements it like
this
<cfset dateString = "11/21/2005">
<cfset dateObj= createdate(2005,11,21)>
<cfform name="dateform" format="flash">
<cfgrid name="dateGrid" height = "120" onChange="gridSelection();" >
<cfgridcolumn name="dateAsString" header="Travel Date">
<cfgridcolumn name="hiddenDate" display="No">
<cfgridrow data ="#dateString#, #dateObj#">
</cfgrid>
<cfformitem type="script">
function gridSelection(){
travelDate.text = dateGrid.selectedItem.dateAsString;
travelDate.selectedDate=dateGrid.selectedItem.hidd enDate;
}
</cfformitem>
<cfinput name="travelDate" type="datefield" label="Travel Date" width="100">
</cfform>
BKBK Guest
-
Chuck1411 #18
Re: changing dateField selectedDate
Just a thought -
But isn't the line
<cfgridrow data ="#dateString#, #dateObj#">
converting the #dateObj# to a string before it is passing into data?
Therefore it is no longer a Date object as you are expecting.
Chuck1411 Guest



Reply With Quote

