I am using Coldfusion 9 cfgrid. I want to do things:
1) Call a javascript function when all data inside cfgrid finish loading.
2) Call a javascript function when we click on next page in pagination.
I am using Coldfusion 9 cfgrid. I want to do things:
1) Call a javascript function when all data inside cfgrid finish loading.
2) Call a javascript function when we click on next page in pagination.
1) use "onload" to specify a javascript function to call when the data has finished loading into the grid.
2) There is no parameter to specify a js function when data is reloaded, but you could get the id or the class of the 'next' button and bind your function to a click event on this element.
For your first question, you could do something like this
// function to fire when grid is finished loading
getTotalRows = function() {
var isGrid = ColdFusion.Grid.getGridObject('myGrid');
var isData = isGrid.getStore();
isData.addListener("load", function() {
if(isData.totalLength == 0) {
alert("No records found");
return false;
}
});
}
ColdFusion.Event.registerOnLoad(getTotalRows,null,false,true);
The last line (CF.Event etc) triggers the function call when the grid is loaded.
http://www.coldfusionjedi.com/index.cfm/2009/4/9/Ask-a-Jedi-Noticing-an-empty-CFGRID