Solved

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

Posted on 2012-04-11
9
1,131 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

739 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