View comments | RSS feed

cfgrid

Description

Used within the cfform tag. Puts a grid control (a table of data) in a ColdFusion form. To specify grid columns and row data, use the cfgridcolumn and cfgridrow tags, or use the query attribute, with or without cfgridcolumn tags.

Category

Forms tags

Syntax

<cfgrid 
name = "name"
format = "applet" or "Flash" or "xml"
height = "integer"
width = "integer"
query = "query_name"
selectMode = "mode"
insert = "yes" or "no"
delete = "yes" or "no"
font = "column_font"
fontSize = "size"
italic = "yes" or "no"
bold = "yes" or "no"
textColor = "web color"
gridLines = "yes" or "no"
rowHeight = "pixels"
colHeaders = "yes" or "no"
colHeaderFont = "font_name"
colHeaderFontSize = "size"
colHeaderItalic = "yes" or "no"
colHeaderBold = "yes" or "no"
colHeaderTextColor = "web color"
bgColor = "web color"
maxRows = "number"
The following works in Flash format only
style= "style specification"
enabled = "Yes" or "No"
visible = "Yes" or "No"
toolTip = "Tip text"
onChange = "ActionScript"
The following work in applet and XML format only
autoWidth = "yes" or "no"
vSpace = "integer"
hSpace = "integer"
align = "value"
sort = "yes" or "no"
href = "URL"
hrefKey = "column_name"
target = "URL_target"
appendKey = "yes" or "no"
highlightHref = "yes" or "no"
onValidate = "javascript_function"
onError = "text"
gridDataAlign = "position"
rowHeaders = "yes" or "no"
rowHeaderAlign = "position"
rowHeaderFont = "font_name"
rowHeaderFontSize = "size"
rowHeaderItalic = "yes" or "no"
rowHeaderBold = "yes" or "no"
rowHeaderTextColor = "web color"
colHeaderAlign = "position"
selectColor = "web color"
notSupported = "text"
pictureBar = "yes" or "no"
insertButton = "text"
deleteButton = "text"
sortAscendingButton = "text"
sortDescendingButton = "text"
onBlur = "actionscript to invoke"
onFocus = "actionscript to invoke">
zero or more cfgridcolumn and cfgridrow tags
</cfgrid>

See also

cfapplet, cfcalendar, cfgridcolumn, cfgridrow, cfgridupdate, cfform, cfformgroup, cfformitem, cfgrid, cfinput, cfselect, cfslider, cftextarea, cftree

History

ColdFusion MX 7 Updater: Added support for the onBlur and onFocus events.

ColdFusion MX 7:

ColdFusion MX: Changed the rowHeaderWidth attribute: ColdFusion does not use the rowHeaderWidth attribute. You can omit it.

Attributes

Note: In XML format, ColdFusion MX passes all attributes to the XML. The supplied XSLT skins do not handle or display XML format grids, but do display applet and Flash format grids.

Attribute Req/Opt; Formats Default Description

name

Required; All

 

Name of the grid control.

format

Optional; All

applet

  • applet: generates a Java applet.
  • Flash: generates a Flash grid control.
  • xml: generates an XML representation of the grid.
    In XML format forms, includes the generated XML in the form.
    In HTML format forms, puts the XML in a string variable with the name specified by the name attribute.

height

Optional; All

300 (applet only)

Height of the control, in pixels.

If you omit the attribute in Flash format, the grid sizes automatically..

width

Optional; All

300 (applet only)

Width of the control, in pixels.

If you omit the attribute in Flash format, the grid sizes automatically.

query

Optional; All

 

Name of the query associated with the control.

selectMode

Optional; All

Applet format: Browse;

Flash format: Row

Selection mode for items in the control.

  • Edit: user can edit grid data. Selecting a cell opens the editor for the cell type.
  • Row: user selections automatically extend to the row that contains selected cell.

The following are used in applet format only; Flash interprets these as Row:

  • Single: user selections are limited to selected cell.
  • Column: user selections automatically extend to column that contains selected cell.
  • Browse: user can only browse grid data.

font

Optional; All

 

Font of text.

fontSize

Optional; All

 

Size of text, in points.

italic

Optional; All

no

  • yes: displays text in italics.
  • no

bold

Optional; All

no

  • yes: displays text in bold.
  • no

textColor

Optional; All

Black

Color of text. Can be a hexadecimal value or a named color.

For a hexadecimal value, use the form "##xxxxxx", where x = 0-9 or A-F; use two number signs or none.

For a list of the supported named colors, see cfchart.

selectColor

Optional; All

 

Background color for a selected item.

  • Options: same as for textColor attribute

gridLines

Optional; All

yes

  • yes: enables row and column rules.
  • no

rowHeight

Optional; All

 

Minimum row height, in pixels. Used with cfgridcolumn type = "Image"; defines space for graphics to display in row.

colHeaders

Optional; All

yes

  • yes: displays column headers.
  • no

colHeaderFont

Optional; All

 

Font of column header.

colHeaderFontSize

Optional; All

 

Size of column header text, in points.

colHeaderItalic

Optional; All

no

  • yes: displays column headers in italics.
  • no

colHeaderBold

Optional; All

no

  • yes: displays column headers in bold.
  • no

colHeaderTextColor

Optional; All

 

Color of column headers.

  • Options: same as for textColor attribute.

bgColor

Optional; All

 

Background color of the control.

  • Options: for applet format, same as for textColor attribute; for Flash format, must be a hexadecimal value.
  • Flash format only: to specify background colors for alternating rows, separate the two colors with a comma.

maxRows

Optional; All

 

Maximum number of rows to display in the grid.

style

Optional;

Flash

 

Must be a style specification in CSS format. Ignored for type="text".

enabled

Optional;

Flash

Yes

Flash format only: Boolean value specifying whether the control is enabled. A disabled control appears in light gray.

visible

Optional;

Flash

Yes

Flash format only: Boolean value specifying whether to show the control. Space that would be occupied by an invisible control is blank.

tooltip

Optional;

Flash

 

Flash format only: text to display when the mouse pointer hovers over the control.

onChange

Optional;

Flash

 

ActionScript to run when the control changes due to user action in the control.

autoWidth

Optional;

applet

no

  • yes: sets column widths so that all columns display within the grid width. Widths are equal or the proportions are determined by the relative cfgridcolumn width attribute values. Horizontal scroll bars are not available.
  • no: sets columns to equal widths or the values specified in the cfgridcolumn width attributes.

vSpace

Optional;

applet

 

Vertical space above and below the control, in pixels.

hSpace

Optional;

applet

 

Horizontal space to the left and right of the control, in pixels.

align

Optional;

applet

 

Alignment of the grid cell contents:

  • Top
  • Left
  • Bottom
  • Baseline
  • Texttop
  • Absbottom
  • Middle
  • Absmiddle
  • Right

insert

Optional;

applet

no

  • yes: users can insert row data in the grid; takes effect only if selectmode="edit".
  • no

delete

Optional;

applet

no

  • yes: users can delete row data from the grid; takes effect only if selectmode="edit".
  • no

sort

Optional;

applet

no

Adds sort buttons to perform simple text sorts on a user-selected column:

  • yes: put sort buttons on the grid control.
  • no

Independent of this setting, users can sort columns by clicking the column head. If selectMode="browse", the table cannot be sorted.

href

Optional;

applet

 

URL or name of a query column that contains URLs to hyperlink each grid cell with.

target

Optional;

applet

 

The target frame or window in which to display the href URL; for example, "_blank".

appendKey

Optional;

applet

yes

  • yes: when used with href, appends "CFGRIDKEY=" and information about the selected items. For details see Using the href attribute.
  • no

hrefKey

Optional;

applet

 

A query column to use for the value appended to the href URL of each cell, if appendKey="True". If you use cfgridcolumn tags, the column must be specified in one of these tags.

highlightHref

Optional;

applet

yes

  • yes: highlights links associated with an href attribute value.
  • no

onValidate

Optional;

applet

 

A JavaScript function to validate user input. The form object, input object, and input object value are passed to the function, which must return True if validation succeeds; False otherwise.

onError

Optional;

applet

 

A JavaScript function to execute if validation fails.

gridDataAlign

Optional;

applet

Left

  • Left: left-aligns data within the column.
  • Right: right-aligns data within the column.
  • Center: centers data within the column.

rowHeaders

Optional;

applet

yes

  • yes: displays a column of numeric row labels.
  • no

rowHeaderAlign

Optional;

applet

Left

  • Left: left-aligns the row header text.
  • Right: right-aligns the row header text.
  • Center: centers the row header text.

rowHeaderFont

Optional;

applet

 

Font for the row labels.

rowHeaderFontSize

Optional;

applet

 

Text size of the row labels, in points.

rowHeaderItalic

Optional;

applet

no

  • yes: displays row label text in italics.
  • no

rowHeaderBold

Optional;

applet

no

  • yes: displays row label text in bold.
  • no

rowHeaderTextColor

Optional;

applet

Black

Text color of grid control row headers.

  • Options: same as for the textColor attribute.

colHeaderAlign

Optional;

applet

Left

  • Left: left-aligns the column header text.
  • Right: right-aligns the column header text.
  • Center: centers the column header text.

notSupported

Optional;

applet

(See Description)

Text to display if the browser does not support Java or has Java support disabled.

Default: "<b> Browser must support Java to view ColdFusion Java Applets</b>"

pictureBar

Optional;

applet

no

  • yes: puts images (and no text) on the Insert, Delete, and Sort buttons.
  • no: puts text (and no images) on the Insert, Delete, and Sort buttons.

insertButton

Optional;

applet

Insert

Insert button text; takes effect only if selectmode="edit".

deleteButton

Optional;

applet

Delete

Delete button text; takes effect only if selectmode="edit".

sortAscendingButton

Optional;

applet

A -> Z

Sort button text.

sortDescendingButton

Optional;

applet

Z -> A

Sort button text.

onBlur

Optional

 

ActionScript that runs when the calendar loses focus.

onFocus

Optional

 

ActionScript that runs when the calendar gets focus.

Usage

This tag must be in a cfform tag block.

An applet format grid requires the client to download a Java applet. Also, if the client does not have an up-to-date Java plugin installed, the system might also have to download an updated Java plugin to display the an applet format grid. A Flash format grid generates a Flash control, and can be embedded in an HTML format cfform tag. For this tag to work properly in either Flash or applet format, the browser must also be JavaScript-enabled.

Note: If you specify Flash format for this tag in an HTML format form, and you do not specify height and width attributes, Flash takes up more than the remaining visible area on the screen. If any other output follows the grid, including any form controls, users must scroll to see it. Therefore, if you follow a Flash grid in an HTML form with additional output, specify height and width values.

You can populate a cfgrid with data from a cfquery. If you do not specify any cfgridcolumn tags in the cfgrid body, ColdFusion generates a grid with the following:

This tag requires an end tag.

Note: Clicking the submit button while editing a grid cell occasionally causes the cell changes to be lost. To ensure that changes are submitted properly, Macromedia recommends that after user updates data in a cell, they click another cell before submitting the form.

How data is returned from cfgrid

This tag returns data by setting form variables in the data submitted to the form's action page, as an HTML form control does. Because the data can vary, depending on the tag's SelectMode attribute value, the form variables that are returned also vary depending on this value.

In general, the data returned falls into one of these categories:

Simple selection data (SelectMode = Single, Column, or Row)

The data that form variables return to the cfform's action page contains information about which cells the user selected. In general, ColdFusion makes this data available in the action page, as ColdFusion variables in the Form scope, with the naming convention form.#GridName#.#ColumnName#

Each SelectMode returns these form variable(s):

Complex update data (SelectMode = Edit)

The grid returns a large amount of data, to inform the action page of inserts, updates or deletes that the user made to the grid. In most cases, you can use the cfgridupdate tag to automatically gather the data from the form variables; the tag collects data, writes SQL calls, and updates the data source.

If you cannot use cfgridupdate (if, for example, you must distribute the returned data to more than one data source), you must write code to read form variables. In this mode, ColdFusion creates the following array variables in the Form scope for each cfgrid:

form.#GridName#.#ColumnName#
form.#GridName#.original.#ColumnName#
form.#GridName#.RowStatus.Action

Each table row that contains an update, insert, or deletion has a parallel entry in each of these arrays. To view all the information for all the changes, you can traverse the arrays, as in this example. To make it work with a cfgrid on a submitted cfform, set the GridName variable to the name of the grid and the ColNameList to a list of the grid columns.

<cfloop index="ColName" list="#ColNameList#">
   <cfif IsDefined("form.#GridName#.#ColName#")>   
      <cfoutput><br>form.#GridName#.#ColName#:<br></cfoutput>
      
      <cfset Array_New = form.[#GridName#][#ColName#]>
      <cfset Array_Orig = form[#GridName#]['original'][#ColName#]>
      <cfset Array_Action = form[#GridName#]RowStatus.Action>
      
      <cfif NOT IsArray(Array_New)>
         <b>The form variable is not an array!</b><br>
      <cfelse>
         <cfset size = ArrayLen(Array_New)>
         <cfoutput> 
         Result Array Size is #size#.<br>
         Contents:<br>
         </cfoutput>
         
         <cfif size IS 0>
            <b>The array is empty.</b><br>
         <cfelse>
            <table BORDER="yes">
               <tr> 
                  <th>Loop Index</TH>
                  <th>Action</TH> 
                  <th>Old Value</TH> 
                  <th>New Value</TH>
               </tr>
               <cfloop index="LoopCount" from="1" to=#size#>   
                   <cfset Val_Orig   = Array_Orig[#LoopCount#]>   
                   <cfset Val_New    = Array_New[#LoopCount#]>   
               <cfset Val_Action   = Array_Action[#LoopCount#]>
               <cfoutput>
               <tr>
                  <td>#LoopCount#</td>
                  <td>#Val_Action#</td>
                  <td>#Val_Orig#</td>
                  <td>#Val_New#</td>
               </tr>
               </cfoutput>
               </cfloop>
            </table>            
         </cfif>         
      </cfif>   

   <cfelse>
      <cfoutput>form.#GridName#.#ColName#: NotSet!</cfoutput><br>   
   </cfif>   
</cfloop>

Using the href attribute

When specifying a URL with grid items using the href attribute, the selectMode attribute value determines whether the appended key value is limited to one grid item or extends to a grid column or row. When a user clicks a linked grid item, a cfgridkey variable is appended to the URL, in this form:

http://myserver.com?cfgridkey=selection

If the appendKey attribute is set to no, no grid values are appended to the URL.

The value of selection is determined by the value of the selectMode and attribute:

Example

The following example creates a Flash form that displays a set of available courses from the CourseList table in the cfdocexamples database. For more complex examples that use the cfgrid tag, see cfgridcolumn, cfgridrow, and cfgridupdate.

<!--- Query the database to fill up the grid. --->
<cfquery name = "GetCourses" dataSource = "cfdocexamples">
SELECT Course_ID, Dept_ID, CorNumber,
CorName, CorLevel
FROM CourseList
ORDER by Dept_ID ASC, CorNumber ASC
</cfquery>

<h3>cfgrid Example</h3>
<I>Currently available courses</i>
<!--- cfgrid must be inside a cfform tag. --->
<cfform>
   <cfgrid name = "FirstGrid" format="Flash"
      height="320" width="580"
      font="Tahoma" fontsize="12"
      query = "GetCourses">
   </cfgrid>
</cfform>

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


aestelker said on Feb 14, 2005 at 10:43 AM :
Is there a way to include horizontal scrolling within the grid?
jrunrandy said on Feb 15, 2005 at 5:46 AM :
aestelker: You need to place the grid inside a <cfformgroup type="vbox or hbox"> with the widths set accordingly. The VBOX will provide the horizontal scroll.
aestelker said on Feb 15, 2005 at 7:18 AM :
jrunrandy: Placing the cfgrid inside of a formgroup does create a horizontal scroll bar, but it has the side effect of placing the vertical scrollbar off screen. This negates the benefits of even using a horizontal scrollbar with this method.
unleashed said on Feb 19, 2005 at 6:01 PM :
Same request... I've been waiting for a year for the flash datagrid and now I can't use it (easily) on any grids that are too wide (which is most of them).

I just don’t see why MM didn’t build a horizontal scrollbar into the flash datagrid.
No screen name said on Feb 19, 2005 at 10:56 PM :
How would you make an item in the cfgrid column be a hyperlink, like link to a master/detail page link or make it be an email link. This is probably easy but im a newbie to CF and iv tried a million things and cant get it
No screen name said on Feb 20, 2005 at 2:11 PM :
whoops i ment to type this code
<cfform method="get" preloader="yes" format="flash" skin="haloblue" height="400">

<cfgrid name="grid" format="flash" query="tenants" autowidth="true" rowheaders="no" height="400" selectmode="single" onChange="getURL('Details.cfm?tenant_id='+grid.selectedItem.tenant_id);">
<cfgridcolumn name="apt_number" header="Apt." width="50">
<cfgridcolumn name="first_name" header="First Name">
<cfgridcolumn name="last_name" header="Last Name">
<cfgridcolumn name="address" header="Address">
<cfgridcolumn name="phone" header="Phone">
<cfgridcolumn name="email" header="Email">
<cfgridcolumn name="tenant_id" display="no">
</cfgrid>

</cfform>
argolnx said on Feb 22, 2005 at 8:16 AM :
Hi. If you put in the example provided in the installation of the server "FLASH" format instead of "APPLET" the form post only empty array. How you can use FLASH cfgrid for updating data?
mattlangston said on Mar 1, 2005 at 11:04 PM :
Is there anyway to highlight a particular row programmatically? Suppose I want to remember the users currently selected row of a <cfgrid> after a form posts back to the server. How do I select that row so that it is highlighted?
jrunrandy said on Mar 8, 2005 at 6:12 AM :
As far as I know, there is no way to highlight a row after a form post back (i.e. maintain and highlight the row selected by the user after the post back)
No screen name said on Mar 10, 2005 at 9:50 AM :
When using a query to populate a grid, is it possible to add additional columns that do not exist in the query (programmatically calculated fields)?
jrunrandy said on Mar 14, 2005 at 2:10 PM :
I can think of two techniques (neither of which I've tried):
* Define the calculated field in the SELECT statement using SQL
* Use the QueryAddColumn function (http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000598.htm)
broon said on Mar 20, 2005 at 7:58 AM :
What is the best way to add record set paging and filtering to a flash grid? I'd like to be able to display a max number of records and then provide the user buttons to page thru the test of the record set.
ZeroOne said on Mar 21, 2005 at 4:26 PM :
If you just put the datagrid inside a cfform (which you have to anyway) and give the cfform a width you will automatically get a horizontal slider if the datagrid is too wide. e.g. if the cfform is 640 wide and the cfgrid is 690 wide.
neilb98 said on Mar 30, 2005 at 6:28 PM :
I managed to get horizontal scrollbars on a CFGRID, but I had to finagle it myself, and its still not a perfect solution. I set the form height to 200px, width680px

I had a TON of data to be displayed in the grid, so I set the width of the grid to 1400, and the height of the grid to this formula: height="#50+(queryname.recordcount * 21)#"

No, this isn't a perfect solution. But it works for me so far.

The email address and website in this login is outdated. Send any comments to neil.bailey@i-dezynes.com/website:www.i-dezynes.com
drew_falkman said on Apr 3, 2005 at 4:36 PM :
When using INSERT in a Flash form, if the user enters multiple new rows, it only allows carries over form information for the last row entered.
No screen name said on Apr 8, 2005 at 4:02 PM :
After setting the GridName and ColNameList variables as follows:
<cfset ColNameList = "parent_su,sd,su,su_owner,eployeeid,fn,ln">
<cfset GridName = "owners_grid">

The Grid Modification Diplay Routine Above Gives the Following Error:

A CFML variable name cannot end with a "." character.
The variable form. ends with a "." character. You must supply an additional structure key or delete the "." character.

The CFML compiler was processing:

* a cfset tag beginning on line 12, column 8.
* a cfset tag beginning on line 12, column 8.
* a cfset tag beginning on line 12, column 8.
* a cfset tag beginning on line 12, column 8.


The error occurred in C:\Program Files\Apache2\htdocs\Workload\owners.cfm: line 12

10 : <cfoutput><br>form.#GridName#.#ColName#:<br></cfoutput>
11 :
12 : <cfset Array_New = form.[#GridName#][#ColName#]>
13 : <cfset Array_Orig = form[#GridName#]['original'][#ColName#]>
14 : <cfset Array_Action = form[#GridName#]RowStatus.Action>
inix said on Apr 17, 2005 at 10:12 AM :
Just realized that you can manipulated the "eanbled" state of another form element on the page on the CFGRID's onChange event.

<CFGRID
onChange="mySubmitButton.enabled=true"...>

<INPUT
TYPE="submit"
name="mySubmitButton"
enabled="FALSE">
...kind of cool
No screen name said on Apr 19, 2005 at 1:25 AM :
I got the same

A CFML variable name cannot end with a "." character.
The variable form. ends with a "." character. You must supply an additional structure key or delete the "." character.

Can anyone help? CFGRIDUPDATE is not working for me so I need to code this manually and unless I can enumerate the fields I am sunk.
billy nasty said on May 18, 2005 at 12:00 AM :
yeah this is the code to insert or delete items from the grid manually

<cfif IsDefined('form.gridname.rowstatus.action')>
<cfloop index="i" from="1" to="#ArrayLen(form.gridname.rowstatus.action)#">
<!--- insert statement--->
<cfif form.gridname.rowstatus.action[i] IS "I">
<cfquery name="Insert" datasource="#Application.dbTravel#">
INSERT INTO _cards (FirmaCC, NummerCC, VervaldatumCC, CUV, ReizigerID)
VALUES ('#form.gridname.FirmaCC[i]#', '#form.gridname.Nummer[i]#', '#form.gridname.VervaldatumCC[i]#', '#form.gridname.CUV[i]#', '169')
</cfquery>

<!--- delete statement--->
<cfelseif form.gridname.rowstatus.action[i] IS "D">
<cfquery name="Delete" datasource="#Application.dbTravel#">
DELETE FROM _cards
WHERE rid=#form.gridname.Original.rid[i]#
</cfquery>
</cfif>
</cfloop>
</cfif>
jrunrandy said on May 25, 2005 at 3:13 PM :
shimmer, I have added enhancement request 60224 in response to your request.

FYI, the Bug Reporting link also allows you to request enhancements.
No screen name said on Jun 1, 2005 at 6:12 PM :
if anyone is still experiencing problems with CFGRID and wants an alternative (which is better and not better depending on your requirements) I have managed to reproduce the functionality using three templates which can be cfinclude'd.

this solution involves straight html, a tiny bit of javascript and stock standard coldfusion code (i.e. no java-based code).

It works a treat (for me) on MX6 and the calling templates are simpler than with cfgrid. Some functionality is missing but then you can code in what you like really if you change the include files.

email me on cfgrid@haroldsteptoe.mailhaven.com if you want copies and a sample.
ccapodilupo said on Jun 7, 2005 at 9:08 AM :
In reponse to -argolnx said on Feb 22, 2005 at 8:16 AM -

Macromedia needs to post a hotfix for <cfgrid format="FLASH"

There is no way for the form to update data on the action page, I hate to gripe but this proably wasn't tested.
brookswift said on Jun 13, 2005 at 1:55 PM :
I'm also having trouble figuring out how to set up a master/detail list in the flash grid. If someone knows how to do that, I'd be very appreciative.
No screen name said on Jun 24, 2005 at 11:16 AM :
For update to work on a flash cfgrid the entire form has to be a flash form.
ASandstrom said on Jul 5, 2005 at 12:53 PM :
Here is a simple code example to go to a different page based on what the user clicks in the grid:

<cfset getclasslist=QueryNew("className, instructor, link")>
<cfset newrow = queryaddrow(getclasslist, 4)>

<cfset temp=querysetcell(getclasslist, "className", "Math", 1)>
<cfset temp=querysetcell(getclasslist, "instructor", "Einstein", 1)>
<cfset temp=querysetcell(getclasslist, "link", "http://localhost:8500/livedocs/mathinfo.cfm", 1)>

<cfset temp=querysetcell(getclasslist, "className", "French", 2)>
<cfset temp=querysetcell(getclasslist, "instructor", "Voltaire", 2)>
<cfset temp=querysetcell(getclasslist, "link", "http://localhost:8500/livedocs/frenchinfo.cfm", 2)>

<cfset temp=querysetcell(getclasslist, "className", "Art", 3)>
<cfset temp=querysetcell(getclasslist, "instructor", "Leonardo", 3)>
<cfset temp=querysetcell(getclasslist, "link", "http://localhost:8500/livedocs/artinfo.cfm", 3)>

<cfset temp=querysetcell(getclasslist, "className", "Gym", 4)>
<cfset temp=querysetcell(getclasslist, "instructor", "Armstrong", 4)>
<cfset temp=querysetcell(getclasslist, "link", "http://localhost:8500/livedocs/gyminfo.cfm", 4)>

<cfform format="Flash" width="500" height="400">
<cfgrid name="classlist"
query="getclasslist"
onchange="getURL(classlist.dataProvider[classlist.selectedIndex]['link']);"
>
<cfgridColumn name="className" header="Subject">
<cfgridColumn name="instructor" header="Instructor">
<cfgridColumn name="link" header="link URL">
</cfgrid>
</cfform>
TheNewb said on Jul 8, 2005 at 12:25 PM :
There seems to be an error in the CFGRID documentation.

The QUERY attribute is marked as being optional, and I know it definitely was in MX 6.1, however it is now required in MX7. A simple grid using this code:

<cfgrid name="myGrid"></cfgrid>

Will throw the following error:

"The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.

Null Pointers are another name for undefined values."

Applying the QUERY attribute works however. Hope this helps!
yukonzach1 said on Jul 17, 2005 at 8:57 PM :
Thank you "No screen name"!! Changing my cfform to format FLASH allowed the update to work!
guessed said on Jul 18, 2005 at 8:12 AM :
The above documentation states that 'insertButton' and 'deleteButton' are only available to the applet format, however when I specify them in a flash grid they (fortunately!) appear.

I have no time to test this, but this 'bug' could also be affecting other parameters.
No screen name said on Jul 20, 2005 at 9:13 AM :
OK I'd appreciate any help because I'm just not getting it. I'm using a cfgrid with two columns and a cfinput text field to pass values to an update page. The user selects a row (they can only select one row) from the grid then enters values in the text field. I don't understand how the cfgrid passes the values to the action page. The documentation description looks different from what I see in the debug on the action page.


here's what i get on the debug of the action page:
(I've added returns and comments)

//this is the value of the textbox;
ORG=1111

__CFGRID__BUDGETOBJECTS__FAO=__CFGRID__COLUMN__=CFGRIDROWINDEX;
__CFGRID__DATA__=11;
__CFGRID__COLUMN__=FUND;
__CFGRID__DATA__=3860;
__CFGRID__COLUMN__=AGENCY;
__CFGRID__DATA__=227;

how do I use this in my insert??
jrunrandy said on Jul 20, 2005 at 2:00 PM :
Good catch. This is a problem in the docs. I ran into it a couple of months ago, but forgot to post a correction to LiveDocs.

Here is why the example doesn't work: form.[#GridName#][#ColName#] isn't really a structure. It's just a variable that happens to have periods in it. So to fix it, replace the following lines:
<cfset Array_New = form[#GridName#][#ColName#]>
<cfset Array_Orig = form[#GridName#]['original'][#ColName#]>
<cfset Array_Action = form[#GridName#]RowStatus.Action>

With the following lines:
<cfset Array_Action = form[GridName &'.RowStatus.Action']>
<cfset Array_New = form[GridName &'.' &ColName]>
<cfset Array_Orig = form[GridName & '.original.' & ColName]>


That should do it. Of course, you also have to set the GridName variable to the name of the grid and the ColNameList variable to a list of the grid columns, as described in the cfgrid page.
coacf said on Jul 20, 2005 at 3:24 PM :
not sure if that really answered my question.

so you're telling me that to simply pass the column/values of a single row i have to convert the data to an array? or is it automatically converted to an array?

i'm not updating the data i'm just using the value to pass into a query
No screen name said on Jul 21, 2005 at 7:04 AM :
the cfgrid applet format does not support onChange event. I tried to submit the form on a change event and it just did not work. I think applets in form are a pain in the neural mass.
jrunrandy said on Jul 21, 2005 at 11:07 AM :
coacf,
Yes. I'm saying that CF converts the data to an array.

If you have additional questions, I suggest that you post them to the online Forum, which has heavier traffic than LiveDocs: http://webforums.macromedia.com/coldfusion
Snake_Hollywood said on Sep 30, 2005 at 5:16 AM :
There appears to be a bug if you try and use multiple instances of CFGRID on the same page (flash).
The columns are repeated for each instance.
I.E. If I have a cfgrid with 2 columns, and I have 6 instances of this on a page, instance 1 has 2 columns, instance 2 has 4 columns, instance 3 has 6 columns etc. And the data is always that form the first instance.

Example code:-
<cfoutput query="components" group="componentID">
<fieldset><legend>#component#</legend>
<cfgrid name="C#componentID#" height="150" width="100%" format="FLASH" insert="No" delete="No" sort="Yes" font="Arial" bold="No" italic="No" autowidth="true" appendkey="No" highlighthref="No" enabled="Yes" visible="Yes" griddataalign="LEFT" gridlines="Yes" rowheaders="No" rowheaderalign="LEFT" rowheaderitalic="No" rowheaderbold="No" colheaders="No" colheaderalign="LEFT" colheaderitalic="No" colheaderbold="No" selectmode="EDIT" picturebar="No">
<cfgridcolumn name="fieldID" headeralign="LEFT" dataalign="LEFT" bold="No" italic="No" select="No" display="No" type="NUMERIC" headerbold="No" headeritalic="No">
<cfgridcolumn name="fieldName" header="Field Name" headeralign="LEFT" dataalign="LEFT" bold="No" italic="No" select="No" display="Yes" type="STRING_NOCASE" headerbold="No" headeritalic="No">
<cfgridcolumn name="data" headeralign="LEFT" dataalign="LEFT" bold="No" italic="No" select="Yes" display="Yes" type="NUMERIC" headerbold="No" headeritalic="No">

<cfoutput>

<cfgridrow data="#fieldID#,#fieldName#,#data#">

</cfoutput>
</cfgrid>

</fieldset>
</cfoutput>
maclonghorn said on Jan 14, 2006 at 6:16 AM :
Apparently, and contrary to the docs, "rowheaders" property is applicable to a Flash form as well as an applet.
EricGyenes said on Jun 14, 2006 at 1:32 PM :
I found a solution to the Horizontal scroll bar issue using actionscript and a trigger AFTER the grid loads.

<cfgrid format="flash" name="myGrid"> ... </cfgrid>

<cfinput type="text"
name="myGridTrigger"
value=""
bind="{ (1==2) ? null : function() {
_root.myGrid.hScrollPolicy = 'on'; }.call() }"
visible="no"
height="0"
width="0" />
No screen name said on Nov 18, 2006 at 2:43 AM :
Should'nt the Description for the onBlur and onFocus attributes be
ActionScript that runs when the grid loses focus.
instead of
ActionScript that runs when the calendar loses focus.
Jools2 said on Jun 7, 2007 at 8:35 AM :
When using a grid in edit mode, populating it with a query of queries breaks the ability of the posted grid to make use of the rowstatus action as per:

<cfloop index="i" from="1" to="#ArrayLen(form.StudentList.rowstatus.action)#">
<cfif form.StudentList.rowstatus.action[i] EQ "D">
<cfset UnivNoList = ListDeleteAt(UnivNoList, ListFind(UnivNoList, form.StudentList.original.Univno[i]))>
</cfif>
</cfloop>


The array returns a 0 length

julian.simpson@bris.ac.uk
No screen name said on Sep 28, 2007 at 11:23 AM :
If you are getting expired certificate warnings, install TechNote b9c2d61c. Certificate then updated to 2010 May 20.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000266.htm