Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 870

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
<cfcomponent>
<cfscript>
remote any function
getEmployees(page,pageSize,gridsortcolumn="EMP_ID",gridsortdirection="ASC"){
var startRow = (page-1)*pageSize;
var endRow = page*pageSize;
if(!isdefined("arguments.gridsortcolumn") or
isdefined("arguments.gridsortcolumn") and trim(arguments.gridsortcolumn) eq "")
gridsortcolumn = "EMP_ID";
if(!isdefined("arguments.gridsortdirection") or
isdefined("arguments.gridsortdirection") and arguments.gridsortdirection eq "")
gridsortdirection = "ASC";
var mysql = "SELECT Emp_ID, FirstName,
if(isdefined("arguments.gridsortcolumn") and arguments.gridsortcolumn neq "")
mysql = mysql & " ORDER BY " & gridsortcolumn;
if(isdefined("arguments.gridsortdirection") and arguments.gridsortdirection neq
"")
mysql = mysql & " " & gridsortdirection ;
rs1 = new query(name="team", datasource="cfdocexamples", sql=mysql).execute();
return QueryConvertForGrid(rs1.getResult(), page, pageSize);
}
remote any function editEmployees(gridaction,gridrow,gridchanged){
writelog("edit employee info");
}
</cfscript>
</cfcomponent>
Employee.cfm
<cfform>
<cfgrid
format="html"
name="grid01"
pagesize=10
title="Employee database"
bind="cfc:mycfcs.employee.getEmployees({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfg
ridsortdirection})"
onChange="cfc:mycfcs.
employee.editEmployees({cfgridaction},{cfgridrow},{cfgridchanged})">
<cfgridcolumn name="Emp_ID" display=false header="ID" />
<cfgridcolumn name="FirstName" display=true header="First Name"/>
<cfgridcolumn name="Email" display=true header="Email"/>
<cfgridcolumn name="Department" display=true header="Department" />
</cfgrid>
</cfform>
Using binding in control attributes
When you use direct binding you specify a bind expression in a ColdFusion form or display control attribute. In the
simplest, form of binding you use form fields, such as a name field, to fill other fields, such as an e-mail field, as the
following example. shows. When you enter a name or domain and tab to click in another field, the name is added to
the e-mail field.
EMail, Department FROM Employees";
Last updated 1/20/2012
865

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents