为什么我的 cfgrid 输出 true/false 而不是 yes/no

发布于 2024-09-13 08:14:57 字数 2229 浏览 1 评论 0原文

我正在处理一些以前使用 cfquery 的代码,现在使用绑定到 cfc 来获取数据。当使用查询时,“workcomplete”列显示是/否(这些是作为文本保存在数据库中的值)。现在它正在使用绑定,该列显示 true/false 而不是 yes/no。它们匹配,即,如果数据库有“否”,cfgrid 将显示“假”,而“是”将显示为“真”。是否可以更改某些设置,以便再次使用数据库中的实际值?

来自 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>

来自 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>

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

懵少女 2024-09-20 08:14:57

由于历史原因,CF 将“是”和“否”视为布尔值。据猜测,我希望 CFGrid 能够这样解释它们,并将它们翻译成更传统的版本。

我要尝试的第一件事是在文本末尾附加一个句点(或一些类似的小转换)。 不过,

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

我目前无法访问我的 CF 服务器来测试这一点。让我知道结果如何。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文