Solved

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

Posted on 2012-04-11
9
1,116 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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

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…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

735 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