Instead of binding the grid to a CFC directly, use the cfajaxproxy. Bind the grid to a JavaScript function, and set the grid's "bindOnLoad" attribute to true so it runs that JavaScript function when the Grid loads the first time. Then, in your JavaScript function, make a call to the CFC proxy and set up a callback handler. When the CFC returns the data, it will run the callback handler function. In the callback function, you can do whatever you want (look at the grid, look at the data that came back from the CFC, etc.) and render your count total. Full details on using cfajaxproxy can be found in the documentation.
On 10/4/07, Azadi Saryev <[EMAIL PROTECTED]> wrote: > > Thanks for your reply, Dale! > > yes, my cfgrid is bound to a cfc.... and you say it won't work then?... > hmm... there must be a way.... > > if i understand you correctly: > ajax UI stuff is loaded and rendered first, and then any data is loaded > into ajax controls; > and ajaxonload() fires inbetween the two? > > it does make sense.... > > so is there any way i can make my showTtlrows js function rnu AFTER the > data is loaded into my cfgrid? > can i somehow "listen" to a loadData or some similar event in the > cfgrid? is there such an event? > > or is having my cfc.function write query.recordcount to a session var > and then outputting that on calling page the only way to return 'total > number of matches found' data? > any other ideas? > > as for wrong count: you are wrong there. calling my js function from a > button click returns correct totalrecords, not per grid page, but total > underlying query.recordcount > if you look at JSON data returned by queryConvertForGrid() function, it > includes TOTALROWCOUNT element which is query.recordcount > > thanks for your help on this - really appreciate it. > > Azadi > > > Dale Fraser wrote: > > If you grid is using a binding, it will not work. > > > > As the Ajax and grid have loaded but the call to get the data hasn't > > occurred yet. Since binded data is paged, it would return the wrong > count > > anyway. > > > > If your grid is not using binding, then im not sure. > > > > Regards > > Dale Fraser > > > > http://learncf.com > > > > -----Original Message----- > > From: Azadi Saryev [mailto:[EMAIL PROTECTED] > > Sent: Thursday, 4 October 2007 1:29 PM > > To: CF-Talk > > Subject: ajaxonload() problem > > > > my second attempt at getting some help here... > > > > i am trying to use a <cfset ajaxonload("showTtlrows")> at the bottom of > > my page to call a js function which gets total number of records from a > > cfgrid (see js code below; yes, the function in itself is correct and > > works). > > my cfgrid is bound to a cfc and works fine. the js function is correct > > and works, too - if i call my js function from an onclick event of a > > button, it works just fine and returns correct number of records from my > > cfgrid. > > > > the ajaxonload() call, however, does not work - it fires after the > > cfgrid is drawn on the page but BEFORE it is populated with data: the > > alert(totalrecords); pops up an alert over an empty cfgrid shell - only > > the header and footer of the cfgrid are there, nothing else (no empty > > rows, no data). > > > > i am far from an ajax pro, and maybe i am misunderstanding thsomething, > > but i was under the impression that ajaxonload() fires after all ajax UI > > elements on the page have fully loaded.... am i wrong? > > how can i make the ajaxonload() call run AFTER my cfgrid is populated > > with data? > > > > thanks for any help! > > > > my js function: > > > > showTtlrows = function(){ > > var mygrid = ColdFusion.Grid.getGridObject('resultsGrid'); > > var mygridData = mygrid.getDataSource(); > > var ttlrecords = mygridData.getTotalCount(); > > //var ttlrecords = mygridData.totalLength; > > alert(ttlrecords); > > //document.getElementById('ttlrows').innerHTML = ttlrecords; > > } > > > > > > -- > > Azadi Saryev > Sabai-dee.com > http://www.sabai-dee.com > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Get the answers you are looking for on the ColdFusion Labs Forum direct from active programmers and developers. http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72&catid=648 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290216 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

