- CFML Reference User Guide
- ColdFusion functions
- ColdFusion functions by category
- Functions a-b
- Abs
- ACos
- AddSOAPRequestHeader
- AddSOAPResponseHeader
- AjaxLink
- AjaxOnLoad
- ApplicationStop
- ArrayAppend
- ArrayAvg
- ArrayClear
- ArrayContains
- ArrayContainsNoCase
- ArrayDelete
- ArrayDeleteAt
- ArrayDeleteNoCase
- ArrayEach
- ArrayFilter
- ArrayFind
- ArrayFindAll
- ArrayFindAllNoCase
- ArrayFindNoCase
- ArrayInsertAt
- ArrayIsDefined
- ArrayIsEmpty
- ArrayLen
- ArrayMap
- ArrayMax
- ArrayMin
- ArrayNew
- ArrayPrepend
- ArrayReduce
- ArrayResize
- ArraySet
- ArraySetMetadata
- ArraySlice
- ArraySort
- ArraySum
- ArraySwap
- ArrayToList
- Asc
- ASin
- Atn
- AuthenticatedContext
- AuthenticatedUser
- BinaryDecode
- BinaryEncode
- BitAnd
- BitMaskClear
- BitMaskRead
- BitMaskSet
- BitNot
- BitOr
- BitSHLN
- BitSHRN
- BitXor
- BooleanFormat
- Abs
- Functions-c-d
- CacheGet
- CacheGetAllIds
- CacheGetMetadata
- CacheGetProperties
- CacheGetSession
- CacheIdExists
- CachePut
- CacheRegionExists
- CacheRegionNew
- CacheRegionRemove
- CacheRemove
- CacheRemoveAll
- CacheSetProperties
- CallStackDump
- CallStackGet
- CanDeSerialize
- Canonicalize
- CanSerialize
- Ceiling
- CharsetDecode
- CharsetEncode
- Chr
- CJustify
- Compare
- CompareNoCase
- Cos
- CreateDate
- CreateDateTime
- CreateObject
- CreateObject: .NET object
- CreateObject: COM object
- CreateObject: component object
- CreateObject: CORBA object
- CreateObject: Java or EJB object
- CreateObject: web service object
- CreateODBCDate
- CreateODBCDateTime
- CreateODBCTime
- CreateSignedJWT
- CreateEncryptedJWT
- CreateTime
- CreateTimeSpan
- CreateUUID
- CSRFGenerateToken
- CSRFVerifyToken
- DateAdd
- DateCompare
- DateConvert
- DateDiff
- DateFormat
- DatePart
- DateTimeFormat
- Day
- DayOfWeek
- DayOfWeekAsString
- DayOfYear
- DaysInMonth
- DaysInYear
- DE
- DecimalFormat
- DecodeForHTML
- DecodeFromURL
- DecrementValue
- Decrypt
- DecryptBinary
- DeleteClientVariable
- Deserialize
- DeserializeJSON
- DeserializeXML
- DirectoryCopy
- DirectoryCreate
- DirectoryDelete
- DirectoryExists
- DirectoryList
- DirectoryRename
- DollarFormat
- DotNetToCFType
- Duplicate
- Functions-e-g
- EncodeForCSS
- EncodeForDN
- EncodeForHTML
- EncodeForHTMLAttribute
- EncodeForJavaScript
- EncodeForLDAP
- EncodeForURL
- EncodeForXML
- EncodeForXMLAttribute
- EncodeForXpath
- Encrypt
- EncryptBinary
- EntityDelete
- EntityLoad
- EntityLoadByExample
- EntityLoadByPK
- EntityMerge
- EntityNew
- EntityReload
- EntitySave
- EntityToQuery
- Evaluate
- Exp
- ExpandPath
- FileClose
- FileCopy
- FileDelete
- FileExists
- FileGetMimeType
- FileIsEOF
- FileMove
- FileOpen
- FileRead
- FileReadBinary
- FileReadLine
- FileSeek
- FileSetAccessMode
- FileSetAttribute
- FileSetLastModified
- FileSkipBytes
- FileUpload
- FileUploadAll
- FileWrite
- FileWriteLine
- Find
- FindNoCase
- FindOneOf
- FirstDayOfMonth
- Fix
- Floor
- FormatBaseN
- GeneratePBKDFKey
- GenerateSecretKey
- GetApplicationMetadata
- GetAuthUser
- GetBaseTagData
- GetBaseTagList
- GetBaseTemplatePath
- GetClientVariablesList
- GetComponentMetaData
- GetContextRoot
- GetCPUUsage
- GetCurrentTemplatePath
- GetDirectoryFromPath
- GetEncoding
- GetException
- GetFileFromPath
- GetFileInfo
- GetFreeSpace
- GetFunctionCalledName
- GetFunctionList
- GetGatewayHelper
- GetHttpRequestData
- GetHttpTimeString
- GetK2ServerDocCount
- GetK2ServerDocCountLimit
- GetLocale
- GetLocaleDisplayName
- GetLocalHostIP
- GetMetaData
- GetMetricData
- GetPageContext
- GetPrinterInfo
- GetPrinterList
- GetProfileSections
- GetProfileString
- GetReadableImageFormats
- GetSafeHTML
- GetSAMLAuthRequest
- GetSAMLLogoutRequest
- GenerateSAMLSPMetadata
- GetSOAPRequest
- GetSOAPRequestHeader
- GetSOAPResponse
- GetSOAPResponseHeader
- GetSystemFreeMemory
- GetSystemTotalMemory
- GetTempDirectory
- GetTempFile
- GetTemplatePath
- GetTickCount
- GetTimeZoneInfo
- GetToken
- GetTotalSpace
- GetUserRoles
- GetVFSMetaData
- GetWriteableImageFormats
- Functions-h-im
- Hash
- HMac
- Hour
- HQLMethods
- HTMLCodeFormat
- HTMLEditFormat
- IIf
- ImageAddBorder
- ImageBlur
- ImageClearRect
- ImageCopy
- ImageCreateCaptcha
- ImageCrop
- ImageDrawArc
- ImageDrawBeveledRect
- ImageDrawCubicCurve
- ImageDrawLine
- ImageDrawLines
- ImageDrawOval
- ImageDrawPoint
- ImageDrawQuadraticCurve
- ImageDrawRect
- ImageDrawRoundRect
- ImageDrawText
- ImageFlip
- ImageGetBlob
- ImageGetBufferedImage
- ImageGetEXIFMetadata
- ImageGetEXIFTag
- ImageGetHeight
- ImageGetIPTCMetadata
- ImageGetIPTCTag
- ImageGetMetadata
- ImageGetWidth
- ImageGrayscale
- ImageInfo
- ImageMakeColorTransparent
- ImageMakeTranslucent
- ImageNegative
- ImageNew
- ImageOverlay
- ImagePaste
- ImageRead
- ImageReadBase64
- ImageResize
- ImageRotate
- ImageRotateDrawingAxis
- ImageScaleToFit
- ImageSetAntialiasing
- ImageSetBackgroundColor
- ImageSetDrawingColor
- ImageSetDrawingStroke
- ImageSetDrawingTransparency
- ImageSharpen
- ImageShear
- ImageShearDrawingAxis
- ImageTranslate
- ImageTranslateDrawingAxis
- ImageWrite
- ImageWriteBase64
- ImageXORDrawingMode
- Functions-in-k
- IncrementValue
- InputBaseN
- Insert
- Int
- InvalidateOauthAccesstoken
- Invoke
- InitSAMLAuthRequest
- InitSAMLLogoutRequest
- InvokeCFClientFunction
- IsArray
- IsAuthenticated
- IsAuthorized
- IsBinary
- IsBoolean
- IsClosure
- IsCustomFunction
- IsDate
- IsDateObject
- IsDDX
- IsDebugMode
- IsDefined
- IsImage
- IsImageFile
- IsInstanceOf
- IsIPv6
- IsJSON
- IsK2ServerABroker
- IsK2ServerDocCountExceeded
- IsK2ServerOnline
- IsLeapYear
- IsLocalHost
- IsNull
- IsNumeric
- IsNumericDate
- IsObject
- isOnline
- IsPDFArchive
- IsPDFFile
- IsPDFObject
- IsProtected
- IsQuery
- isSamlLogoutResponse
- isSafeHTML
- IsSimpleValue
- IsSOAPRequest
- IsSpreadsheetFile
- IsSpreadsheetObject
- IsStruct
- IsUserInAnyRole
- IsUserInRole
- IsUserLoggedIn
- IsValid
- IsValidOauthAccesstoken
- IsWDDX
- IsXML
- IsXmlAttribute
- IsXmlDoc
- IsXmlElem
- IsXmlNode
- IsXmlRoot
- JavaCast
- JSStringFormat
- Functions-l
- LCase
- Left
- Len
- ListAppend
- ListChangeDelims
- ListContains
- ListContainsNoCase
- ListDeleteAt
- ListEach
- ListFilter
- ListFind
- ListFindNoCase
- ListFirst
- ListGetAt
- ListInsertAt
- ListLast
- ListLen
- ListMap
- ListPrepend
- ListQualify
- ListReduce
- ListRemoveDuplicates
- ListRest
- ListSetAt
- ListSort
- ListToArray
- ListValueCount
- ListValueCountNoCase
- LJustify
- Location
- Log
- Log10
- LSCurrencyFormat
- LSDateFormat
- LSDateTimeFormat
- LSEuroCurrencyFormat
- LSIsCurrency
- LSIsDate
- LSIsNumeric
- LSNumberFormat
- LSParseCurrency
- LSParseDateTime
- LSParseEuroCurrency
- LSParseNumber
- LSTimeFormat
- LTrim
- Functions-m-r
- Max
- Mid
- Min
- Minute
- Month
- MonthAsString
- Now
- NumberFormat
- ObjectEquals
- ObjectLoad
- ObjectSave
- OnWSAuthenticate
- ORMClearSession
- ORMCloseAllSessions
- ORMCloseSession
- ORMEvictCollection
- ORMEvictEntity
- ORMEvictQueries
- ORMExecuteQuery
- ORMFlush
- ORMFlushall
- ORMGetSession
- ORMGetSessionFactory
- ORMIndex
- ORMIndexPurge
- ORMReload
- ORMSearch
- ORMSearchOffline
- ParagraphFormat
- ParameterExists
- ParseDateTime
- Pi
- PrecisionEvaluate
- ProcessSAMLResponse
- ProcessSAMLLogoutRequest
- Quarter
- PreserveSingleQuotes
- QueryAddColumn
- QueryAddRow
- QueryConvertForGrid
- QueryExecute
- QueryFilter
- QueryGetResult
- QueryGetRow
- QueryKeyExists
- QueryMap
- QueryNew
- QueryReduce
- QuerySetCell
- QuotedValueList
- QueryEach
- Rand
- Randomize
- RandRange
- ReEscape
- REFind
- REFindNoCase
- ReleaseComObject
- REMatch
- REMatchNoCase
- RemoveCachedQuery
- RemoveChars
- RepeatString
- Replace
- ReplaceList
- ReplaceNoCase
- REReplace
- REReplaceNoCase
- RestDeleteApplication
- RestSetResponse
- RestInitApplication
- Reverse
- Right
- RJustify
- Round
- RTrim
- Functions-s
- Second
- SendGatewayMessage
- SendSAMLLogoutResponse
- Serialize
- SerializeJSON
- SerializeXML
- SessionInvalidate
- SessionRotate
- SessionGetMetaData
- SessionInvalidate
- SessionRotate
- SetDay
- SetEncoding
- SetHour
- SetLocale
- SetMonth
- SetProfileString
- SetVariable
- SetYear
- Sgn
- Sin
- Sleep
- SpanExcluding
- SpanIncluding
- SpreadsheetAddAutoFilter
- SpreadsheetAddColumn
- SpreadsheetAddFreezePane
- SpreadsheetAddImage
- SpreadsheetAddInfo
- SpreadsheetAddPageBreaks
- SpreadsheetAddRow
- SpreadsheetAddRows
- SpreadsheetAddSplitPane
- SpreadsheetCreateSheet
- SpreadsheetDeleteColumn
- SpreadsheetDeleteColumns
- SpreadsheetDeleteRow
- SpreadsheetDeleteRows
- SpreadsheetFormatCell
- SpreadsheetFormatColumn
- SpreadsheetFormatCellRange
- SpreadsheetFormatColumn
- SpreadsheetFormatColumns
- SpreadsheetFormatRow
- SpreadsheetFormatRows
- SpreadsheetGetCellComment
- SpreadsheetGetCellFormula
- SpreadsheetGetCellValue
- SpreadsheetGetColumnCount
- SpreadsheetInfo
- SpreadsheetMergeCells
- SpreadsheetNew
- SpreadsheetRead
- SpreadsheetReadBinary
- SpreadsheetRemoveSheet
- SpreadsheetSetActiveSheet
- SpreadsheetSetActiveSheetNumber
- SpreadsheetSetCellComment
- SpreadsheetSetCellFormula
- SpreadsheetSetCellValue
- SpreadsheetSetColumnWidth
- SpreadsheetSetFooter
- SpreadsheetSetHeader
- SpreadsheetSetRowHeight
- SpreadsheetShiftColumns
- SpreadsheetShiftRows
- SpreadsheetWrite
- Sqr
- StripCR
- StructAppend
- StructClear
- StructCopy
- StructCount
- StructDelete
- StructEach
- StructFilter
- StructFind
- StructFindKey
- StructFindValue
- StructGet
- StructGetMetadata
- StructInsert
- StructIsEmpty
- StructKeyArray
- StructKeyExists
- StructKeyList
- StructMap
- StructNew
- StructReduce
- StructSetMetadata
- StructSort
- StructToSorted
- StructUpdate
- StoreSetMetadata
- StoreGetACL
- StoreGetMetadata
- StoreAddACL
- StoreSetACL
- Functions-t-z
- Tan
- ThreadJoin
- ThreadTerminate
- Throw
- TimeFormat
- ToBase64
- ToBinary
- ToScript
- ToString
- Trace
- Transactionandconcurrency
- TransactionCommit
- TransactionRollback
- TransactionSetSavePoint
- Trim
- UCase
- URLDecode
- URLEncodedFormat
- URLSessionFormat
- Val
- ValueList
- VerifyClient
- Week
- Wrap
- WriteDump
- WriteLog
- WriteOutput
- WSGetAllChannels
- WSGetSubscribers
- WSPublish
- WSSendMessage
- XmlChildPos
- XmlElemNew
- XmlFormat
- XmlGetNodeType
- XmlNew
- XmlParse
- XmlSearch
- XmlTransform
- XmlValidate
- Year
- YesNoFormat
- ColdFusion Tags
- ColdFusion tag summary
- ColdFusion tags by category
- Application framework tags
- Communications tags
- Database manipulation tags
- Data output tags
- Debugging tags
- Exception handling tags
- Extensibility tags
- File management tags
- Flow-control tags
- Forms tags
- Internet Protocol tags
- Page processing tags
- Security tags
- Variable manipulation tags
- Other tags
- Tags a-b
- Tags c
- Tags f
- cffeed
- cffile
- cffile action = "append"
- cffile action = "copy"
- cffile action = "delete"
- cffile action = "move"
- cffile action = "read"
- cffile action = "readBinary"
- cffile action = "rename"
- cffile action = "upload"
- cffile action = "uploadAll"
- cffile action = "write"
- cffileupload
- cffinally
- cfflush
- cfform
- cfformgroup
- cfformitem
- cfftp
- cfftp: Connection: file and directory operations
- cfftp: Opening and closing FTP server connections
- cfftp : Opening and closing secure FTP server connections
- cfftp action = "listDir"
- cffunction
- Tags g-h
- Tags i
- Tags j-l
- cfjava
- cflayout
- cflayoutarea
- cfldap
- cflocation
- cflock
- cflog
- cflogin
- cfloginuser
- cflogout
- cfloop
- cfloop : conditional loop
- cfloop : index loop
- cfloop : looping over a COM collection or structure
- cfloop : looping over a date or time range
- cfloop : looping over a list, a file, or an array
- cfloop : looping over a query
- Tags m-o
- cfmail
- cfmailparam
- cfmailpart
- cfmap
- cfmapitem
- cfmediaplayer
- cfmenu
- cfmenuitem
- cfmessagebox
- cfmodule
- cfNTauthenticate
- cfoauth
- cfobject
- cfobject: .NET object
- cfobject: COM object
- cfobject: component object
- cfobject: CORBA object
- cfobject: Java or EJB object
- cfobject: web service object
- cfobjectcache
- cfoutput
- Tags p-q
- Tags r-s
- Tags t
- Tags u-z
- CFML Reference
- Reserved words and variables
- Ajax JavaScript functions
- Ajax JavaScript functions
- Function summary Ajax
- ColdFusion.Ajax.submitForm
- ColdFusion.Autosuggest.getAutosuggestObject
- ColdFusion.Layout.enableSourceBind
- ColdFusion.MessageBox.getMessageBoxObject
- ColdFusion.ProgressBar.getProgressBarObject
- ColdFusion.MessageBox.isMessageBoxDefined
- JavaScriptFunctionsinColdFusion9Update1
- ColdFusion ActionScript functions
- ColdFusion mobile functions
- Application.cfc reference
- Script functions implemented as CFCs
- ColdFusion Flash Form style reference
- Styles valid for all controls
- Styles for cfform
- Styles for cfformgroup with horizontal or vertical type attributes
- Styles for box-style cfformgroup elements
- Styles for cfformgroup with accordion type attribute
- Styles for cfformgroup with tabnavigator type attribute
- Styles for cfformitem with hrule or vrule type attributes
- Styles for cfinput with radio, checkbox, button, image, or submit type attributes
- Styles for cftextarea tag and cfinput with text, password, or hidden type attributes
- Styles for cfselect with size attribute value of 1
- Styles for cfselect with size attribute value greater than 1
- Styles for cfcalendar tag and cfinput with dateField type attribute
- Styles for the cfgrid tag
- Styles for the cftree tag
- ColdFusion Flash Form Style Reference
- ColdFusion event gateway reference
- ColdFusion Event Gateway reference
- addEvent
- CFEvent
- CFEventclass
- Constructor
- Gateway development interfaces and classes
- getStatus
- setCFCPath
- setCFCMethod
- getOriginatorID
- getLogger
- getBuddyList
- getBuddyInfo
- IM gateway message sending commands
- IM Gateway GatewayHelper class methods
- onIncomingMessage
- onIMServerMessage
- onBuddyStatus
- onAddBuddyResponse
- onAddBuddyRequest
- IM Gateway CFC incoming message methods
- IM gateway methods and commands
- CFML CFEvent structure
- warn
- info
- setOriginatorID
- data command
- submit Multi command
- submit command
- setGatewayType
- setGatewayID
- setData
- setCFCListeners
- outgoingMessage
- getStatusTimeStamp
- numberOfMessagesReceived
- numberOfMessagesSent
- removeBuddy
- removeDeny
- removePermit
- setNickName
- setPermitMode
- setStatus
- SMS Gateway CFEvent structure and commands
- SMS Gateway incoming message CFEvent structure
- getStatusAsString
- getProtocolName
- getPermitMode
- getPermitList
- getNickName
- getName
- getDenyList
- getCustomAwayMessage
- getQueueSize
- getMaxQueueSize
- getHelper
- getGatewayType
- getGatewayServices
- getGatewayID_1
- getGatewayID
- getData
- getCFCTimeout
- setCFCTimeout
- getCFCPath
- getCFCMethod
- GatewayServices class
- Gateway interface
- GatewayHelper interface
- addPermit
- addDeny
- addBuddy
- error
- debug
- Logger class
- stop
- start
- CFML event gateway SendGatewayMessage data parameter
- restart
- fatal
- SMS gateway message sending commands
- ColdFusion C++ CFX Reference
- ColdFusion Java CFX reference
- WDDX JavaScript Objects
- Cloud services
- ColdFusion and GCP Storage
- ColdFusion and GCP Firestore
- ColdFusion and GCP PubSub
- ColdFusion and Amazon S3
- ColdFusion and DynamoDB
- ColdFusion and Amazon SQS
- ColdFusion and Amazon SNS
- ColdFusion and MongoDB
- ColdFusion and Azure Blob
- ColdFusion and Azure Service Bus
- Multi-cloud storage services
- Multi-cloud RDS databases
- ColdFusion and Azure Cosmos DB
FORMAT="applet" HAS BEEN DEPRECATED
For a full list of deprecated features, refer to Deprecated features.
Description
Used in 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.
For CFC methods that returns numeric data with a leading zero, for example, zip code 02674, the zero is interpreted by the bind expression as an octal number and its decimal equivalent (in this case 1468) even if you set returnformat="string". To resolve this issue, for URL binds or binds routed by way of a JavaScript function (for example, using cfajaxproxy), you can set returnformat=plain to retain the numeric value. Also, leading zeros are stripped from the suggestion list for autosuggest controls.
Category
Syntax
<cfgrid> name="name" align="value" appendKey="yes|no" autoWidth="yes|no" bgColor="web color" bind="bind expression" bindOnLoad="yes|no" bold="yes|no" colHeaderAlign="left|right|center" colHeaderBold="yes|no" colHeaderFont="font_name" colHeaderFontSize="size" colHeaderItalic="yes|no" colHeaders="yes|no" colHeaderTextColor="web color" collapsible="false|true" delete="yes|no" deleteButton="text" enabled="yes|no" font="column_font" fontSize="size" format="html|xml" gridDataAlign="left|right|center" gridLines="yes|no" groupfield="column name" height="integer" highlightHref="yes|no" href="URL" hrefKey="column_name" hSpace="integer" insert="yes|no" insertButton="text" italic="yes|no" maxRows="number" multirowselect="yes|no" notSupported="text" onBlur="ActionScript" onChange="ActionScript or bind expression" onError="JavaScript function name" onFocus="ActionScript function" onLoad="JavaScript function name" onValidate="JavaScript function name" pageSize="number of rows" pictureBar="yes|no" preservePageOnSort="yes|no" query="query name" resetHead="true|false" rowHeaderAlign="left|right|center" rowHeaderBold="yes|no" rowHeaderFont="font name" rowHeaderFontSize="size" rowHeaderItalic="yes|no" rowHeaders="yes|no" rowHeaderTextColor="web color" rowHeight="pixels" selectColor="web color" selectMode="mode" selectOnLoad="yes|no" sort="yes|no" sortAscendingButton="text" sortDescendingButton="text" stripeRowColor="web color" stripeRows="yes|no" style= "style specification" target="URL_target" textColor="web color" title="text" tooltip="text" visible="yes|no" vSpace="integer" width="integer"> <cfgrid> zero or more cfgridcolumn and cfgridrow tags
You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys. |
See also
cfajaximport, cfapplet, cfcalendar, cfgridcolumn, cfgridrow, cfgridupdate, cfform, cfformgroup, cfformitem,
cfinput, cfselect, cfslider, cftextarea, cftree, Using HTML grids in the Developing ColdFusion Applications
History
ColdFusion (2024 release): Changed default value of format to html.
ColdFusion 11 Update 11: Added the attribute resetHead.
ColdFusion 9.0.1: Added the attribute multirowselect , supported only in HTML grids.
ColdFusion 9:
- Added collapsible, groupfield , onLoad, and title attributes, supported in HTML grids only.
- Added ability to use the insert attribute in HTML grids.
ColdFusion 8: Added support for HTML format grids, including the html value of the format attribute and the following attributes: bind, bindOnLoad, pageSize, preservePageOnSort, stripeRows, stripeRowColor.ColdFusion MX 7.01: Added support for the onBlur and onFocus events.ColdFusion MX 7: - Added the format attribute and support for Flash and XML output.
- Added enabled, onChange, style, tooltip, and visible attributes (Flash format only).
ColdFusion MX: Changed the rowHeaderWidth attribute: ColdFusion does not use the rowHeaderWidth attribute. You can omit it.
Attributes
Attribute | Req/Opt; formats | Default | Description |
---|---|---|---|
name | Required; all | Name of the grid control. | |
align | Optiona | Alignment of the grid cell contents:
|
|
appendKey | Optional;HTML | yes |
|
autoWidth | Optional;HTML | no |
|
bgColor | Optional; all | Background color of the control. For most formats, can be a hexa-decimal format 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.
|
|
bind | Optional; HTML | A bind expression used to fill the contents of the grid. Cannot be used with the query attribute. For more information, see Binding data to form fields in Using Ajax Data and Development Features in the Developing ColdFusion Applications. | |
bindOnLoad | Optional; HTML | yes |
|
bold | Optional; all | no |
|
colHeaderAlign | Optional | left |
|
colHeaderBold | Optional; all | no |
|
colHeaderFont |
Optional; all | Font of column header. | |
colHeaderFontSize | Optional; all | Size of column header text, in points. | |
colHeaderItalic | Optional; all | no |
|
colHeaders | Optional Flash | yes |
|
colHeaderTextColor | Optional; all | Color of column headers.
|
|
collapsible | Optional; HTML | False | A Boolean value specifying whether the user can collapse the entire grid by clicking an arrow on the title bar. Specifying this attribute adds a title bar to the grid. |
delete | Optional;HTML | no |
|
deleteButton | Optional;HTML | Delete | Text for the Delete button; takes effect only if selectmode="edit". |
enabled | Optional;Flash | yes | Flash format only: Boolean value that specifies whether the control is enabled. A disabled control appears in light gray. |
font | Optional; all | Font of text. | |
fontSize | Optional; all | Size of text, in points. | |
format | Optional; all | html |
|
gridDataAlign | Optional; | left |
|
gridLines | Optional; | yes |
|
groupField | Optional; HTML | Don't group | Puts the grid rows into groups, organized by the column specified in this attribute. Each group is collapsible and has a header with the column name, group field value, and number of entries in the group. If you set this option, the column pull-down menu shows two grouping options: The show in Groups option turns column grouping on and off. The Group By This Field option sets the grouping to use the selected column. Users display the pull-down menu by moving the mouse over a column head and clicking the down arrow that appears You can use this attribute with static grids only, do not use it with dynamic grids that get their data using bind expressions. |
height | Optional; all | 300 | Height of the control, in pixels. If you omit the attribute in Flash format, the grid sizes automatically. |
highlightHref | Optional | yes |
|
href | Optional;HTML | URL or name of a query column that contains URLs to hyperlink each grid cell with. | |
hrefKey | Optional;HTML | 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. | |
hSpace | Optional; | Horizontal space to the left and right of the control, in pixels. | |
insert | Optional;HTML | no |
|
insertButton | Optional; | Insert | Text for the Insert button; takes effect only if selectmode="edit". |
italic | Optional; all | no |
|
maxRows | Optional; all | Maximum number of rows to display in the grid. | |
multirowselect | Optional; HTML | no | Allows selection of multiple rows. This is particularly useful in the cases where batch processing is required, for example, moving multiple records at a time. Note: If multirowselect="yes", then row data is sent as an array of structs as opposed to a struct if mutirowselect="no". Also, if the grid data is manipulated by the user, for example, using JavaScript, to move records when a button is clicked, set the method to POST. This is required as a GET method imposes restrictions on the amount of data that can be sent. |
notSupported | Optional; | See Description | Text to display if the browser does not support Java or has Java support disabled. |
onBlur | Optional, Flash | ActionScript that runs when the grid loses focus. | |
onChange | Optional;HTML, Flash | Flash format: ActionScript to run when the control changes due to user action in the control.HTML format: Required for HTML format grids that specify a bind attribute and a selectMode value of edit. A bind expression that calls a CFC method, JavaScript function, or URL to update the data source. If a URL is called, since the data is passed in JSON format to the URL page, use the function DeserializeJSON. The arguments cfgridrow and cfgridchanged must be serialized to JSON strings if a JavaScript bind is used to pass these arguments to a URL. | |
onError | Optional;HTML | In HTML format grids, name of a JavaScript function to execute if an error occurs. |
|
onFocus | Optional,Flash | ActionScript that runs when the grid gets focus. | |
onLoad | Optional | A custom JavaScript function to execute when the grid is loaded and rendered. | |
onValidate | Optional; | 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. | |
pageSize | Optional;HTML | 10 | The number of rows to display per page for a dynamic grid. If the number of available rows exceeds the page size, the grid displays only the specified number of entries on a single page, and the user navigates between pages to show all data. The grid retrieves data for each page only when it is required for display. This attribute is ignored if you specify a query attribute. |
pictureBar | Optional; | no |
|
preservePageOnSort | Optional; HTML | no | Specifies whether to display the page with the current page number, or display page 1, after sorting (or resorting) the grid. If this attribute is yes, selections are preserved when the grid sorts. |
query | Optional; all | Name of the query associated with the control. Cannot be used with the bind attribute. | |
resetHead | Optional; HTML | If true then clears <head> tag. | |
rowHeaderAlign | Optional; | left |
|
rowHeaderBold | Optional; | no |
|
rowHeaderFont | Optional; | Font for the row labels. | |
rowHeaderFontSize | Optional; | Text size of the row labels, in points. | |
rowHeaderItalic | Optional; | no |
|
rowHeaders | Optional; | yes |
|
rowHeaderTextColor | Optional; | black | Text color of grid control row headers.
|
rowHeight | Optional XML |
Minimum row height, in pixels. Used with cfgridcolumn type = "Image"; defines space for graphics to display in row. | |
selectColor | Optional; all | Background color for a selected item.
|
|
selectMode | Optional; all | Selection mode for items in the control.
|
|
selectOnLoad | Optional; HTML | yes |
|
sort | Optional; | no | Adds sort buttons to perform simple text sorts on a user-selected column:
|
sortAscendingButton | Optional; | A > Z | Text for the Sort button. |
sortDescendingButton | Optional; | Z > A | Text for the Sort button. |
stripeRowColor | Optional; HTML | The color to use for one of the alternating stripes. The bgColor setting determines the other color. | |
stripeRows | Optional; HTML | no | Boolean value that indicates whether to make the rows stripes in alternating colors. |
style | Optional;Flash | Must be a style specification in CSS format. Ignored for type="text". | |
target | Optional;HTML, | The target frame or window in which to display the href URL; for example, "_blank". | |
textColor | OptionalFlash, | 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. | |
title | Optional; HTML | Text to display as a title at the top of the grid. Specifying this attribute adds a title bar to the grid. | |
tooltip | Optional;Flash | Flash format only: text to display when the mouse pointer hovers over the control. | |
visible | Optional;Flash | yes | Flash format only: Boolean value that specifies whether to show the control. Space that would be occupied by an invisible control is blank. |
vSpace | Optional; | Vertical space above and below the control, in pixels. | |
width | Optional; all | 300 | Width of the control. |
Usage
Most of the following paragraphs describe grid features that apply to all, or at least two, grid formats. For information that is specific to Flash forms, see Creating Forms in Flash in the Developing ColdFusion Applications. For information that is specific to HTML format grids, see Using HTML grids in the Developing ColdFusion Applications.
This tag must be in a cfform tag block.
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:
- A column for each column in the query.
A default header for each column, created by replacing hyphen or underscore characters in the table column name with spaces. The first character, and any character after a space, are changed to uppercase; all other characters are lowercase.
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, Adobe recommends that after user updates data in a cell, they click another cell before submitting the form.
Returning cfgrid data to the action page
The following information applies to all cfgrid formats. Also, HTML format grids can dynamically get data by using a bind expression. For more information, see Using HTML grids in the Developing ColdFusion Applications.
When a user submits a form, the cfgrid tag sends information about user actions by setting form variables in the data submitted to the form's action page. 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 data, returned from simple select operations
- Complex data, returned from insert, update, and delete operations
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 variables:
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"
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), 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# |
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:
- If you specify a hrefKey attribute, selection is the field value of the column specified by the attribute. Otherwise, it is one of the following:
- If selectMode="Single", selection is the value of the column clicked.
- If selectMode="Row", selection is a comma-delimited list of column values in the clicked row, beginning with the value of the first cell in the row.
- If selectMode="Column", selection is a comma-delimited list of row values in the clicked column, beginning with the value of the first cell in the column.
When you use an href attribute, you can also specify a target attribute with any of the standard HTML target specifiers, _blank, _parent, _self, and _top, or with a specific frame name.
Enhancements made in ColdFusion 9.0.1
- In ColdFusion 9, data for the first row is available on form submission in a form with dynamic grid. In ColdFusion 9.0.1, the data is not available.
- If the type is Boolean and selectmode is browse, or select=false, the column is shown as a check box where click does not take effect.
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>