Thanks guys!
Anthony's hint help me out to solve this.
If somebody is interested on how I did it, here's the code:
def search():
users = SQLFORM.grid(db.users,
fields=[db.users.id, db.users.facebook_id, db.users.first_name, db.
users.last_name, db.users.birthday],
sortable=False, deletable=False, editable=False, create=False,
csv=False, paginate=20)
users.element('.web2py_grid')['_id'] = 'root' #giving an id to the grid
container for personal purposes
users.element('.web2py_grid')['_class'] = 'row' #giving a class name
to the grid container for personal purposes
users.element('.web2py_counter')[0] = '' #i dont want the 'X results
found' message
users[0].element('.web2py_console')['_class'] = '' #full width search
input
users[0][1][0][1] = '' #remove search button
users[0][1][0][2] = '' #remove clear button
users[0][1][0][0]['_onfocus'] = None #remove event from input
users[0][1][0][0]['_placeholder'] = 'Buscar usuarios...'
users[0][1][1] = ''
table_div = users.element('.web2py_table')
table_div[0] = ''
table_div['_class'] = 'row'
try:
users[2] #checking that pagination exists
except Exception, e: #if it does not exists
for i in range(0, len(users.rows)):
table_div.insert(-1,
DIV(
A(IMG(_src="http://graph.facebook.com/"+ str(users.rows[
i].facebook_id)+"/picture?type=large",_class="media-object",_width="100",
_height="100")
,_class="pull-left",_href=URL('operator','user_profile',
args=users.rows[i].id)),
DIV(H4(users.rows[i].first_name+' '+users.rows[i].
last_name),
SPAN(users.rows[i].birthday,_class="birthday"),'
años',
BR(),
A('Ver detalles',_href=URL('operator','user_profile'
,args=users.rows[i].id),_class="btn btn-primary", _role="button"),
_class="media-body")
,_class="media col-md-4",_style="margin-top:0px;")
)
else: #pagination exists!
users[2][0]['_class'] = 'pagination'
for i in range(0, len(users.rows)):
table_div.insert(-1,
DIV(
A(IMG(_src="http://graph.facebook.com/"+ str(users.rows[
i].facebook_id)+"/picture?type=large",_class="media-object",_width="100",
_height="100")
,_class="pull-left",_href=URL('operator','user_profile',
args=users.rows[i].id)),
DIV(H4(users.rows[i].first_name+' '+users.rows[i].
last_name),
SPAN(users.rows[i].birthday,_class="birthday"),'
años',
BR(),
A('Ver detalles',_href=URL('operator','user_profile'
,args=users.rows[i].id),_class="btn btn-primary", _role="button"),
_class="media-body")
,_class="media col-md-4",_style="margin-top:0px;")
)
return dict(users=users)
And this is how it looks (I changed my mind and ended using media-objects
instead of thumbnails for users long names situations):
With pagination(I forced paginate=1 'cause I have only three users):
<https://lh5.googleusercontent.com/-Pfwad2y2wHg/VBEUxvMxAsI/AAAAAAAABYs/aEAO0VKYPvs/s1600/Screen%2BShot%2B2014-09-11%2Bat%2B00.18.23.png>
Without pagination:
<https://lh6.googleusercontent.com/-jo7oy8j-pco/VBEWkxst6hI/AAAAAAAABY0/t1VHx73j4_4/s1600/Screen%2BShot%2B2014-09-11%2Bat%2B00.27.02.png>
Thanks a lot for your help!
Cheers!
On Wednesday, September 10, 2014 11:36:06 AM UTC-3, Anthony wrote:
>
> Are you saying you don't want each record in an HTML table row but instead
> want to display each record as a card? There's no built-in way to do that,
> but you can hack the returned grid object and replace the HTML table with
> your own DOM:
>
> def my_custom_grid_layout(rows):
> [code to produce the desired DOM from a DAL Rows object]
>
> grid = SQLFORM.grid(db.mytable)
> table_div = grid.element('.web2py_table')
> if table_div:
> table_div[0] = my_custom_grid_layout(grid.rows)
>
> You'll have to write your own code to generate the layout you want.
>
> Anthony
>
> On Wednesday, September 10, 2014 1:35:12 AM UTC-4, Luciano Laporta Podazza
> wrote:
>>
>> Hello,
>>
>> I would like to take advantage of SQLFORM.grid search, listing and
>> pagination capabilities to generate a listing from a table, but I need to
>> customize the resulting rows like this:
>>
>>
>> <https://lh3.googleusercontent.com/-TbnhU4p9EOw/VA_hxFcXi_I/AAAAAAAABYI/Ti2JNW4AdAg/s1600/Screen%2BShot%2B2014-09-10%2Bat%2B02.23.35.png>
>> Until now I only have this:
>>
>> users = SQLFORM.grid(db.users,fields=[db.users.id, db.users.first_name,
>> db.users.last_name],
>> headers={'users.id':'id','users.first_name':'Nombre',
>> 'users.last_name':'Apellido'},
>> sortable=False, deletable=False, editable=False, create=False,
>> csv=False, formstyle="div")
>>
>> Which results into this:
>>
>>
>> <https://lh4.googleusercontent.com/-E7cySzUy2Bw/VA_iuQU_5CI/AAAAAAAABYQ/n5mLgALWJcs/s1600/Screen%2BShot%2B2014-09-10%2Bat%2B02.33.16.png>
>> I'm using Bootstrap 3. Any help will be appreciated.
>>
>>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.