Copy link to clipboard
Copied
i'm trying to get the rowcount of a cfgrid on cf9, and if 0 switch a message to user.
i've tried a js attached to the onLoad of the cfgrid, keeps throwing Expected ')' and i don't see where?
function getGridData() {
var mygrid = ColdFusion.Grid.getGridObject('cApps');
var mydata = mygrid.getStore();
rowCountVal = mydata.totalLength;
alert(rowCountVal);
}
thanks for any help
Copy link to clipboard
Copied
Comment out every line and add them back one at a time until the error occurs. If it happens with all lines commented out, look at the code that calls it.
Copy link to clipboard
Copied
thanks Dan, it's the cfgrid onload thrwoing the error. i've tried:
onload="javascript:getGridData"
onload="javascript:getGridData()"
onload="javascript:getGridData({cfgridaction}, {cfgridrow} {cfgridchanged})"
nothing works
also tried instead the <cfset ajaxOnLoad="getGridData">, it doesn't throw an error but doesn't return the rowcount either
thanks again
Copy link to clipboard
Copied
Where is your onload code in your document? I'm assuming that if its a regular onLoad attribute of an HTML element (e.g. <Body>, then you don't need the "javascript:" prefix. Otherwise, what happens if you pop an alert box at the top of your getGridData() method and comment out the rest - are you getting the alert box or is the error occuring before the function can even be called?
Copy link to clipboard
Copied
it's the onLoad attribute of a cfgrid of type HTML
the cfgrid syntax seems to be correct, onLoad="javascript:getGridData()", i'm using one other event for the same grid and it works fine:
onchange="javascript:showData({cfgridaction}, {cfgridrow}, {cfgridchanged})"
nothing happens if i put the alert at the top of the function, get the same error. looks like the error happens before the function executes.
what's worse, i don't think the onLoad event of the grid actually works. i've tried a different method: the cfgrid is bound to the onkeyup event of a text box, srcApps. i've modified this text box like <input type="text" name="srcApps" setTimeout('getGridData()',1000);"> adding a 1 second delay before executing the function.
this works, but only when i type something in srcApps, and only when using <cfset ajaxOnLoad="getGridData"> at the end of the page, not with the grid onLoad event. if i remove the 1 second delay in the srcApps definition, it stops working, which i think proves onLoad never kicks off
thanks