CFGRID布尔列是/否 [英] cfgrid boolean column as Yes/No

查看:220
本文介绍了CFGRID布尔列是/否的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个HTML CFGRID一个boolean类型列。数据被存储在数据库中为1/0,并从CF返回这样。我希望用户看到的是/否,而不是1/0。我试过QuerySetCell,并不能得到它的工作。

I have a boolean type column in an html cfgrid. The data is stored in the database as 1/0 and is returned from CF as such. I want the user to see Yes/No instead of 1/0. I tried QuerySetCell, and couldn't get it to work.

形式为可编辑的,当你双击单元格,复选框显示,当它应该在更新。唯一的问题是显示。

The form is editable, when you double click the cell, the checkboxes show and it updates as it should. The only issue is the display.

<cfform>
   <cfgrid name="blah" format="html" bind="mycfccall" selectmode="edit">
      <cfgridcolumn name="bitCol" header="Is it" width="75" type="boolean">
   </cfgrid>
</cfform>

在此先感谢...

Thanks in advance...

推荐答案

您需要应用自定义字段渲染器。你需要一个init()js函数添加到您的网页,以渲染方法一起。我有我的博客应用自定义渲染的基本过程:

You'll need to apply a custom field renderer. You'll need to add an init() js function to your page, along with a renderer method. I have the basic process of applying a custom renderer on my blog:

CF8阿贾克斯电网:渲染器和活动

基本上,你会打电话给你的init()方法后,电网已初步呈现,通过使用ajaxOnLoad()方法:

Basically, you'll call your init() method after the grid has initially rendered, by using the ajaxOnLoad() method:

<cfset ajaxOnLoad("init") />

在你的init()方法,你会得到对电网的引用,它的ColumnModel:

Within your init() method, you would get a reference to the grid and it's ColumnModel:

init = function() {
    var myGrid = ColdFusion.Grid.getGridObject('myGridID');
    var gridCM = myGrid.getColumnModel();
    // The rest goes here
}

您还需要你的渲染方法,可以适用于任何列:

You'll also need your renderer method, that you can apply to any column:

yesNoRenderer = function(value,meta,record,row,column,store) {
    if (value === 1){
    	return "Yes";
    } else {
    	return "No";
    }
}

在这之后,你需要渲染应用到你选择的列:

After which, you'll need to apply the renderer to the column of your choice:

gridCM.setRenderer(cm.getIndexById('myColumnName'), yesNoRenderer);

该setRenderer方法将列索引(从0开始),并申请成为渲染器的功能。该getIndexById()方法应该在这里工作,但你应该测试它第一次予以肯定,并记住,套管在JavaScript中是很重要的。

The setRenderer method takes the column index (starting from 0) and the function to apply as a renderer. The getIndexById() method should work here, but you should test it first to be sure, and remember that casing is important in JavaScript.

大多数CF Ajax组件的使用分机1.1引擎盖下。通过在 Col​​dFusion的JavaScript函数的Adobe的文档,请仔细阅读,并记住,你可以挖掘到潜在的分机1.1 API

Most of the CF Ajax components use Ext 1.1 under the hood. Carefully read through The Adobe documentation on the ColdFusion JavaScript Functions, and remember that you can tap into the underlying Ext 1.1 API.

这篇关于CFGRID布尔列是/否的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆