thanks Brian,

your reply made me try the js bind again*, and this time i managed to 
make it work... well, sort of...

* = i have tried it before but gave up after a lot of js and ajax 
debugger errors... i was just not passing the data to my grid properly.

i have corrected and added a few lines of js and it works - it does 
populate the grid with data AND populates my div with totalrecords - 
BUT... it also always pops up an annoying 'CFGRID: Response is empty' 
alert!!!
if i use ?cfdebug, it does not pop the alert up (but does log it in 
debugger)...

it also keeps popping up same alert when i try re-sorting the grid by 
clicking on column headers AND when i use the pagination controls!!!
and that's when the data is in the grid already!

what can i do???  how can i make it NOT mind the absence of 
response/data? or how can i suppress/disable this pop-up alert?

i have tried bindonload=false with another ajaxonload() call to refresh 
the grid and all sorts of combinations of the two, i have tried adding a 
row to the grid with <cfgridrow...>
nothing worked so far...

any ideas? really appreciate all the help.


Azadi


Brian Kotek wrote:
> 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
>>
>>
>>
>>     
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion 8 - Build next generation apps
today, with easy PDF and Ajax features - download now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290256
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to