?
Solved

Use CFGrid selectedItem as a form value

Posted on 2005-04-28
2
Medium Priority
?
1,045 Views
Last Modified: 2013-12-24
Can the selectedItem variable be refrenced in a form submission?  I am not sure if I am asking that right so here is an example:

OK, I have this grid in a form-->

<cfform action="anotherpage.cfm">
     <cfgrid name="Grid" query="Grid">
          <cfgridcolumn name="ColumnOne" header="Column One">
     </cfgrid>
</cfform>

Can it be refrenced in the submission of that form if a value is highlighted in that grid?

Example:
<cfquery datasource="Table">
     INSERT INTO tableOne (GridItemNumber)
     VALUES ('#Form.Grid.selectedItem.ColumnOne#')
</cfquery>

Again i am not sure if I am making sense to anyone.
0
Comment
Question by:myerit
2 Comments
 
LVL 5

Accepted Solution

by:
8riaN earned 2000 total points
ID: 13895675
Yes, you can do this so long as you are not using CFGrid to edit the data.  If all the user needs to be able to do is select a cell, column, or row, this works fine.

The key change from your code is that you don't need selectedItem, and you have to set the SelectMode.

so lets say you want the click to select a row, and then reference column1 in that row, your code would look like this:
<cfform action="anotherpage.cfm">
     <cfgrid name="Grid" query="GridQuery" SelectMode="row">
          <cfgridcolumn name="ColumnOne" header="Column One">
          <cfgridcolumn name="ColumnTwo" header="Column Two">
          <!--- ... etc.  --->
     </cfgrid>
</cfform>

and in anotherpage.cfm ->
<cfquery datasource="Table">
     INSERT INTO tableOne (GridItemNumber)
     VALUES ('#Form.Grid.ColumnOne#')
</cfquery>
this will insert the value of ColumnOne in the query GridQuery (in the first .cfm file) for the row selected by the user on the cfgrid "Grid" into the column called GridItemNumber in the table tableOne

Which is what you want to do, right?

8riaN

Here's the relevent section from the help file:

If the SelectMode attribute equals Single, Column, or Row, the data returned by form variables to the cfform's ACTION page contains information about which cell or cells were selected by the user. In general, this data is made available by ColdFusion in the ACTION page as ColdFusion variables in the form scope using the following naming convention:

form.#GridName#.#ColumnName#.
Specifically, each SelectMode returns the following form variable(s):

SelectMode="single"
form.#GridName#.#ColumnName# = "SelectedCellValue"

SelectMode="column"
form.#GridName#.#ColumnName# = "ValueOfCellRow1, ValueOfCellRow2, ... ValueOfCellRowN"

SelectMode="row"
form.#GridName#.#Column1Name# ="ValueOfCellInSelectedRow"

form.#GridName#.#Column2Name# = "ValueOfCellInSelectedRow"

form.#GridName#.#ColumnNName# = "ValueOfCellInSelectedRow"

0
 

Author Comment

by:myerit
ID: 13895804
You are a genius!

Thanks much, that is exactly what I needed!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Integration Management Part 2
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month16 days, 19 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question