views:

40

answers:

1

I am working on some code that previously was using a cfquery, and is now using bind to a cfc to get the data. When it was using the query, the column 'workcomplete' showed yes/no (These are the values saved in the database as text). Now that it is using bind, that column is showing true/false instead of yes/no. They match, ie, if the database has 'No', the cfgrid shows 'False' and 'Yes' comes up as 'True'. Is there some setting that can be changed so that it will use the actual values from the database again?

From the cfml:

              <cfform>
          <cfgrid format="html" name="list" striperows="yes" fontsize="12" pagesize="25" selectmode="row" bind="cfc:joborder.getJoborders({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})">

              <cfgridcolumn name="dispatchnum"   header="Dispatch Num" href="job.cfml" hrefkey="jobid" width="100"/>
              <cfgridcolumn name="submitdate"   header="Submit Date" width="90">
              <cfgridcolumn name="jobname"   header="Job Name" width="200"  >
              <cfgridcolumn name="contactlast"  header="Contact Last Name" width="150" >
              <cfgridcolumn name="workcomplete"   header="Completed" width="100" >
              <cfgridcolumn name="jobid"   header="Edit " href="jobedit.cfml" hrefkey="jobid" width="40" />
              <cfgridcolumn name="editdate"   header="Edit Date" width="80"/>
              <cfgridcolumn name="jobid"   header="DELETE" hrefkey="jobid" width="60" href="delete.cfml?jobid=url.jobid">                                                  
          </cfgrid>
          </cfform>

From the cfc:

<cffunction name="getJoborders" access="remote">
  <cfargument name="page" required="yes">
  <cfargument name="pageSize" required="yes">
  <cfargument name="gridsortcolumn" required="yes">
  <cfargument name="gridsortdirection" required="yes">

 <cfif arguments.gridsortcolumn eq "">
     <cfset arguments.gridsortcolumn = "dispatchnum" />
     <cfset arguments.gridsortdirection = "desc" />
 </cfif>

   <cfquery datasource="jobs" name="joborders">
  SELECT DISPATCHNUM, SUBMITDATE, WORKCOMPLETE, EDITDATE, JOBID, ORDERNUM, JOBNAME, CONTACTFIRST, CONTACTLAST
  FROM JOBORDERS
  <cfif gridsortcolumn neq ''>
  order by #arguments.gridsortcolumn# #arguments.gridsortdirection#
  </cfif>

Thanks!

+1  A: 

For historical reasons, "yes" and "no" are treated as booleans by CF. At a guess, I would expect that CFGrid is interpreting them as such, and translating them into a more traditional version.

The first thing I would try is to append a period to the end of the text (or some similar minor transformation). Something along the lines of

select workcompleted + '.' as workcompleted.....

I don't currently have access to my CF server to test this, though. Let me know how it works out.

Ben Doom
Yes, adding a period worked, so I tried it out with a space and that worked as well. That will do as a workaround, thanks!
slavalle