Here is a working example, there is a grid page and a cfc for
the grid data. As it is an example from the online docs it should
just work for you.
Note that there is no need to rebuild the paging toolbar each
time, all you want to do is hide/show the column.
If this is not what you want email me your pages with an
explination of what you want to achieve and I will see what I can
do.
info at scarecrowapplications.com
grid page
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<cfset intShowRows = 5>
<script>
initDIA = function(){
var grid = ColdFusion.Grid.getGridObject('searchGrid');
var cm = grid.getColumnModel();
var gridFoot = grid.getView().getFooterPanel(true);
ds = grid.getDataSource();
// add a paging toolbar to the grid's footer
var paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: <cfoutput>#intShowRows#</cfoutput>,
displayInfo: true,
displayMsg: 'Displaying records {0} - {1} of {2}',
emptyMsg: "No records to display"
});
// add a Please Wait Message on submittals
grid.loadMask = true;
//setstartuppermissions();
customizeGrid();
//setFocus();
}
function customizeGrid(){
var grid = ColdFusion.Grid.getGridObject('searchGrid');
var cm = grid.getColumnModel();
//load the grid
ds.load({params:{start:0,limit:<cfoutput>#intShowRows#</cfoutput>}});
//returns true if the particular radio button is selected
var booDocumentImaging =
document.frmSearchGrid.strsearchdb[0].checked;
var booFilenet =
document.frmSearchGrid.strsearchdb[1].checked;
// Now show/hide grid columns and data details based on
default or user choice
if (booDocumentImaging) {
//document.getElementById('divFilenetFields').style.display
= 'none';
//document.getElementById('divDocumentImagingFields').style.display
= 'block';
//setHidden(colIndex, hidden)
cm.setHidden(0,true);
}
// If true then Filenet was selected
else if (booFilenet) {
//document.getElementById('divFilenetFields').style.display
= 'block';
//document.getElementById('divDocumentImagingFields').style.display
= 'none';
// Filenet does not need the ability to add an attachment
//document.getElementById('btnaddAttachment').disabled='true';
//setHidden(colIndex, hidden)
cm.setHidden(0,false);
}
}
</script>
</head>
<body>
<cfform name="frmSearchGrid">
<cfinput type="radio" name="strsearchdb" value="1"
onClick="customizeGrid()">
<cfinput type="radio" name="strsearchdb" value="0"
onClick="customizeGrid()">
<cfgrid format="html" name="searchGrid" pagesize="5"
sort="true" autowidth="true"
bind="cfc:places.getData({cfgridpage},{cfgridpagesize},
{cfgridsortcolumn},{cfgridsortdirection})">
<cfgridcolumn name="Emp_ID" display=true header="eid"
/>
<cfgridcolumn name="FirstName" display=true
header="Name"/>
<cfgridcolumn name="Email" display=true header="Email"
/>
</cfgrid>
</cfform>
<cfset ajaxOnLoad("initDIA") />
</body>
</html>
cfc page (places.cfc)
<cfcomponent>
<cffunction name="getData" access="remote"
output="false">
<cfargument name="page">
<cfargument name="pageSize">
<cfargument name="gridsortcolumn">
<cfargument name="gridsortdirection">
<cfquery name="team" datasource="cfdocexamples">
SELECT Emp_ID, FirstName, EMail
FROM Employees
<cfif gridsortcolumn neq "" or gridsortdirection neq
"">
order by #gridsortcolumn# #gridsortdirection#
</cfif>
</cfquery>
<cfreturn QueryConvertForGrid(team, page, pageSize)>
</cffunction>
</cfcomponent>
Ken