Cfgrid boolean column as Yes / No

I have a boolean type column in html cfgrid. Data is stored in the database as 1/0 and returned from the 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 on a cell, check boxes are displayed, and it is updated as needed. The only problem is the mapping.

<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...

+3
source share
2 answers

. init() js . :

CF8 Ajax Grid:

, init() ajaxOnLoad():

<cfset ajaxOnLoad("init") />

init() ColumnModel:

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

, :

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

:

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

setRenderer ( 0) , . getIndexById() , , , JavaScript.

CF Ajax Ext 1.1 . Adobe JavaScript ColdFusion , Ext 1.1 API.

+6

, Decode:

Decode(bitCol,1,'Yes','No') bitCol
+1

Source: https://habr.com/ru/post/1708683/


All Articles