Groups | Blog | Home
all groups > coldfusion flash integration > august 2006 >

coldfusion flash integration : CFGRID/CFSELECT/ActionScript problem



ttedeschi
8/18/2006 8:40:06 PM
I have CFGRID "onchange" code below that allows me to click on a CFGRID row and
correctly display (in a separate CFFORMGROUP) the correct column value in via a
CFSELECT object. The field name is
[i]priority[/i] and the grid name is
[i]tasks_grid[/i].

Works fine, but my problem is that I've been unable to get this to work on
non-integer fields. If the field contains a text string, no matter how small,
the ActionScript "if" statements don't seem to produce results. Could it be
incorrect use of the == operator? I'm not an AS programmer, so I'm
unfortunately on the low end of the learning curve here.

I hope the above makes sense. Any thoughts would be greatly appreciated.


<cfgrid name="tasks_grid"
height=400
width=420
vspace=10
selectmode="row"
query="getTasks"
insert="no"
delete="no"
rowheaders="false"
onchange="
for (var i:Number = 0; i<priority.length; i++) {if
(priority.getItemAt([i]).data == tasks_grid.selectedItem.priority)
priority.selectedIndex = i}
for (var i:Number = 0; i<assignedTo.length; i++) {if
(assignedTo.getItemAt([i]).data == tasks_grid.selectedItem.assignedTo)
assignedTo.selectedIndex = i}
for (var i:Number = 0; i<serviceID.length; i++) {if
(serviceID.getItemAt([i]).data == tasks_grid.selectedItem.serviceID)
serviceID.selectedIndex = i}
for (var i:Number = 0; i<type.length; i++) {if (type.getItemAt([i]).data ==
tasks_grid.selectedItem.type) type.selectedIndex = i}
">
ttedeschi
8/22/2006 9:12:35 PM
So far the best solution seems to be to create an array for each such field
that creates a new query column containing the text data. I then reference the
new "text" column ("priorityText", in this instance) via CFGRIDCOLUMN and use
the original "integer" column (i.e., the actual field data) for the
ActionScript matching code in the child form. The array code is from another
post, in the Rich Forms forum, I believe.



<cfset priorityArray = ArrayNew(1)>
<cfloop query="GetTasks">
<cfif GetTasks.priority is "0">
<cfset ArrayAppend(priorityArray, "Low")>
<cfelseif GetTasks.priority is "1">
<cfset ArrayAppend(priorityArray, "Normal")>
<cfelseif GetTasks.priority is "2">
<cfset ArrayAppend(priorityArray, "High")>
</cfif>
</cfloop>
<cfset QueryAddColumn(GetTasks, "priorityText", priorityArray)>
jedale
8/30/2006 5:19:12 PM
Make sure that your ".data" field for the cfselect is comparable to the ".type"
field of the cfgrid.

set up alerts and put different variables in the the ++ section like the
following...
alert('Type: '+tasks_grid.selectedItem.type+'');
put this in your if statements and see where it gets you

Jeff

AddThis Social Bookmark Button