• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

can't get cfgrid rowcount

Participant ,
Nov 11, 2011 Nov 11, 2011

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

TOPICS
Advanced techniques

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 11, 2011 Nov 11, 2011

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 11, 2011 Nov 11, 2011

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 11, 2011 Nov 11, 2011

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 14, 2011 Nov 14, 2011

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation