为什么我的 cfgrid 输出 true/false 而不是 yes/no
我正在处理一些以前使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于历史原因,CF 将“是”和“否”视为布尔值。据猜测,我希望 CFGrid 能够这样解释它们,并将它们翻译成更传统的版本。
我要尝试的第一件事是在文本末尾附加一个句点(或一些类似的小转换)。 不过,
我目前无法访问我的 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
I don't currently have access to my CF server to test this, though. Let me know how it works out.