Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 833

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
The following example shows the getdata.cfm page:
<!--- Empty string; the default end of the query SQL. --->
<cfset queryEnd="">
<cfquery name="team" datasource="cfdocexamples">
SELECT Emp_ID, FirstName, EMail
FROM Employees
<cfif sortcol neq "" or sortdir neq "">
order by #sortcol# #sortdir#
</cfif>
</cfquery>
<!--- Format the query so that the bind expression can use it. --->
<cfoutput>#serializeJSON(QueryConvertForGrid(team, page, pageSize))#
</cfoutput>
If your database lets you specify SQL to retrieve only the required page of data in a query, you can optimize efficiency
by using such a query. Do not use the QueryConvertForGrid function. Instead, manually create the return structure
and return only the single page of data. Ensure that you set the TotalRowCount field to the number of rows in the entire
data set, not the number of rows in the returned page of data.
Using the bindOnLoad attribute
The
attribute causes a control to execute its bind expression immediately when it loads, and not wait until
bindOnLoad
the event that normally triggers the bind expression evaluation to occur. This way, the control can be filled with an
initial value. This attribute is
and
, for which it is
cfgrid
true
populated when they load.
When a control with a
truebindOnLoad
and second control load themselves at the
change event from the second control when that control completes loading. So, the first control makes two Ajax calls,
whereas it must make only one, when the second control finished loading.
Because the
,
cfinput
cfselect
encounter any problems if a
attributes. However, if the control does set its
bindOnLoad
attribute to
to ensure that the control only fetches data when the control that it is bound to returns.
false
You can also get a double loading if a grid binds to a Spry data set. By default, the grid and data set load data at page
load, and then the grid loads data again in response to a selection change event from the data set when it sets focus to
its first row. Set
bindOnLoad
event from the data set.
Dynamically editing grid contents
When you use a bind expression to get
user input, without requiring the user to submit the form. You can use dynamic updating to update or delete data in
the data source. (To edit
cfgrid
in the row and click the delete button at the bottom of the grid.)
You cannot insert new rows directly in a grid that uses a bind expression. To add rows, enter the data in a form, and
make sure that the grid refreshes after the form has been submitted.
by default for all ColdFusion Ajax controls that have the attribute, except
false
by default
Having a
.
truebindOnLoad
attribute is bound to a control that also binds when the page loads, the first
page event. Then the first control loads itself again in response to a
onLoad
, and
control
cftextarea
or
tag binds to any of these controls and you do not explicitly set the
cfgrid
cfdiv
to
to ensure that the grid fetches data only when it receives a selection
false
data dynamically, you can also update the data source dynamically with
cfgrid
data, select the contents of a field and type the new value; to delete a row, select a field
Last updated 1/20/2012
value on these controls ensures that they are
attributes are
bindOnLoad
false
attribute to
bindOnLoad
true
cfdiv
by default, you do not
, set the
or
cfgrid
cfdiv
change
828

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents