grid - hiding reconds found count

501 views
Skip to first unread message

peter

unread,
Oct 30, 2011, 6:00:12 AM10/30/11
to web2py-users
I am hoping that the developers of SQLFORM.grid will add an option to
hide the 'nn records found' message. In fact I do not think it should
appear at all when there is no search in place. I have discovered a
neat way of hiding this message
Put in your layout.html (or more locally if you wish)
<style>
.web2py_counter { display:none}
</style>

Put it just before {{include}}
Unfortunately it leaves a gap, but it is much better way of getting
rid of the message than editing gluon.

Peter

Anthony

unread,
Oct 30, 2011, 10:21:01 AM10/30/11
to web...@googlegroups.com
You can also get rid of it using server side DOM manipulation:

del grid[0][2]  # the web2py_counter div is the third component within the first div of the returned grid object

Anthony

Mandar Vaze

unread,
Sep 3, 2012, 4:08:54 AM9/3/12
to web...@googlegroups.com
I understand this is quite old thread - posting so that it may be relevant for others ..

While I was using about "Version 2.00.0 (2012-07-26 06:06:10) dev"  from github, instead of grid[0][2] I had to use grid[0][1]
When I upgraded to "Version 2.0.2 (2012-08-30 04:08:18) stable" - The above code started given me an error "list index out of range"
Little debugging showed me that now the "records found" was at grid[0][0]

My code given below for reference. (Following code did not change between the two versions of web2py, except grid[0][]0] which was grid[0][1] earlier.)

    grid = SQLFORM.grid(somequery, create=False, deletable=False,  
                  searchable
=False, csv=False, editable=False, details=False,        
                  sortable
=False, fields=[db.table.field1, db.table.field2])              
   
if somequery.count() > 0:                                                
         
del grid[0][0]  # Delete "n records found" text


-Mandar

P.S : I understand that I'm using only the SQLFORM portion of SQLGRID (details, edit and delete all set to false), but that is a problem to be solved another day ...

Anthony

unread,
Sep 3, 2012, 4:35:56 AM9/3/12
to web...@googlegroups.com
Actually, to make the code more clear and to avoid issues with changing subscripts, it's generally best to use the .elements() and .element() methods rather than subscripting. In the past, however, this didn't work if you needed to replace or remove an element, but now you can do that as well. In this case, you can do:

grid.element('.web2py_counter', replace=None)

Anthony

Mandar Vaze / मंदार वझे

unread,
Sep 3, 2012, 5:39:23 AM9/3/12
to web...@googlegroups.com
Yes. Works !!
This is great - much cleaner solution.

Thanks Anthony 

-Mandar

--
 
 
 

Reply all
Reply to author
Forward
0 new messages