Solved

Is it possible to get recordcount on a cfgrid? Dynamically?

Posted on 2012-04-11
9
1,106 Views
Last Modified: 2012-04-13
I have a cfgrid on a page that is built with some default query arguments. On that page I have a form that I allow users to to enter information in and then submit. When the form is submitted I send some arguments to the cfgrid query and display the grid with the new query requirements. I am using an HTML cfgrid with bind.

Is is possible to write the recordcount of the query to the page dynamically? When a user "filters" items in the grid I'd like the recordcount to update as well.

My grid/query are all very basic but if some example code is needed please let me know.

Thank you.
0
Comment
Question by:earwig75
  • 5
  • 4
9 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 37834837
Can you post a screen shot? Because iirc, cfgrid should do that automatically.
0
 

Author Comment

by:earwig75
ID: 37834862
cfgrid only gives the pages, for example: 1 of 3 not a record count.

I found this post but it doens't seem to work... even when I use getStore instead of getDataSource.

Thanks again.
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 37834899
Some of the cfgrid/javascript stuff changed between 8/9. You're using CF9 right?
http://thecfguy.com/post.cfm/showing-record-information-in-cfgrid-footer-in-coldfusion-9

The code in that link works for me.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:earwig75
ID: 37838359
Yes, I am using CF9. This seems to work but I get a script error in IE. "Object expected" on this line in the ext-all.js script "var d=n.dom.firstChild.offsetWidth;"

Do you also get this script error in IE? I looked around online and I find that everyone has this problem but I can't find a solution.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37838826
No, I typically use FF.  I cannot test it now, but will try it w/IE later.

everyone has this problem

Everyone meaning those using CFGRID or even people using extJS? If it's the latter, then it may be an EXT bug.
0
 

Author Comment

by:earwig75
ID: 37839215
Everyone meaning those using CFGRID or even people using extJS? If it's the latter, then it may be an EXT bug.

I found the solution you posted in a few other places and it seems like many people report having the same problem. I can't seem to find a work-around. Are there any other ways to get the record count of a grid - possibly outside of the bottom toolbar where this one puts it?

Thanks again.
0
 

Author Closing Comment

by:earwig75
ID: 37840456
This solution works but produces a javascript error in the ext .js
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37841195
Finally got a chance to test with IE, and got the same error. IE is annoying sometimes... Anyway:

Are there any other ways to get the record count of a grid - possibly outside of the bottom toolbar where this one puts it?

I saw an example (somewhere?) of how to use a title bar. But it only shows the total records. Not sure how to get the current range working ie showing records x - y

               (Can't test it right now)

            <script  type="text/javascript">
                  var gridRender = function()
                  {
                             grid = ColdFusion.Grid.getGridObject('myGrid');
                             grid.store.on('load', function( ds ) {
                                 grid.setTitle('Total records: '+ grid.store.getTotalCount());
                             });
                         };  
            </script>
                ....
               <cfgrid title=""  ...rest of attributes >
                ....
0
 

Author Comment

by:earwig75
ID: 37842158
I saw an example (somewhere?) of how to use a title bar. But it only shows the total records.

This works perfectly, thank you.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question