[web2py] SQLFORM.grid() and Search

843 views
Skip to first unread message

Richard

unread,
May 1, 2013, 1:59:07 PM5/1/13
to web...@googlegroups.com
Hello,

I did some research about SQLFORM.grid() Search Question and I summarize what I found here :

Search requirements for me to use SQLFROM.grid() in place of Datatables.net :

  1. Need to be able to search the representation for referenced fields (Solved)
  2. No database field name in the Query Builder...
    • I would like the labels to be used in the Query Builder and then be translated into the proper query passed to the URL (Open, a solution seems to exist)
  3. User should have the option to search over all the fields (like Datatables.net search/filter) (Open, a solution seems to exist)

1) I was searching a way to search representation of a referenced field and I found this answer (from Niphold) :

How to search referenced field (query with join) :
https://groups.google.com/d/msg/web2py/Z4HZNNLlyYs/lknATE2iKJoJ


2) But then, I realize that for the construction of the search the user has to know the database fields names (the labels are not taking into account by the query builder) in order to create his search... 

I try to solve that with SQLFROM.grid headers=HEADERS_DICT, but still the query constructor display the database field name and not there labels...

About that issue, I found this thread that seem to address the problem into a elegant way :


So, the solution seems to exist, but I would have to implement my own or reuse this one... Did this had been (could be) added built-in in SQLFORM.grid()??

3) I would like to preserve something I consider as a "feature". Actually I use Datatables.net almost every where I need a grid, and my users know how use the search/filter of Datatables, so I would have this option into SQLFORM.grid()...

I found this share :

Again, I have to test and see how it fit beside the query builder... Having to different input search may be weird for user or lead to misunderstanding.


Is there other important things I should know about SQLFORM.grid() and search?

What the future for a better search experience with SQLFORM.grid()?

I think the greatest advantage of SQLFORM.grid() over other Javascript grid for instance is the ability to create a search and share it to other user as a link... Of course there is also the possibility to create more complexe query than a simple filter box. And I want these features in my app.

Richard

Other thread :


Related :

Niphlod

unread,
May 1, 2013, 3:27:04 PM5/1/13
to web...@googlegroups.com
uhm......
2. seems hard but not impossible. However, what do you need specifically ? instead of auth_user.first_name="hello" just First name="hello" or whatever suites me best=Hello? What if some column names collide ?
3. unless you're referring to custom-coded filters in datatables.net, all it has is a single input that searches all fields in a "contains()" manner, i.e. if you put "a" in it it will filter all the rows where "a" is found in any column. That's what grid does by default if you put "a" in the main input field and press "search".

In other words, current search widget is easy enough for every user out there, extremely flexibile while retaining a "quick" way to search through your table ..... we can shift that balance a little but up to a certain point: it kinda has to suite everybody's needs.

Richard Vézina

unread,
May 1, 2013, 4:23:23 PM5/1/13
to web2py-users
Wasn't know about your explanation for point 3 (contains() manner), so this one seems to be solved. Will test if we can do, a <space that mean &> b to make sure it search for a & b in association in all the columns though...

About 2, I agree with you it is a bigger challenge. But I think it could work at least for single table, because it makes no sens to give the same label twice into the same table. In case of join, the issue could be solve the same way we do with web2py query adding the tablename. Only difference we should use a label for table name there too and web2py has no notion of table label...

table_name_label.field_name_label !=, ==, etc. value searched

This map into :

table_name.field_name==value searched

?

Richard


--
 
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Cliff Kachinske

unread,
May 1, 2013, 4:47:16 PM5/1/13
to web...@googlegroups.com
I like the latest search in grid/smartgrid a lot.  A very nice piece of work.

I do have a tiny concern about exposing table names to the world at large, though.  Maybe it would be possible to obfuscate the table name by presenting the plural of the table.  

Richard Vézina

unread,
May 2, 2013, 10:46:24 AM5/2/13
to web2py-users
Maybe I should update, because with web2py 2.3.2 I can't search a la "contains" in all the columns...

Richard

Niphlod

unread,
May 2, 2013, 2:16:39 PM5/2/13
to web...@googlegroups.com
uhm, ok. try the trunk version, then post your requirements with examples, and then I'll surely take a look into it, ok ?

Richard Vézina

unread,
May 2, 2013, 3:00:50 PM5/2/13
to web2py-users
Ok, no improvement on contains like search in trunk...

I will try to make a dummy app with table a fields labelled and explain how the search could behave in case someone want to obfuscate the database table and field names...

Richard
Reply all
Reply to author
Forward
0 new messages