Requesting button names for grid and smartgrid

18 views
Skip to first unread message

Paul Ellis

unread,
Jan 4, 2018, 4:15:00 PM1/4/18
to web2py-users
Would it be possible to name the grid buttons and smartgrid table links?

This would make it pretty easy to tweak the buttons.
For example. I would like to change the Delete button to red.
I can do it like this:
rowBtns = grid.elements('div', _class = 'row_buttons')
if rowBtns:
   
for row in rowBtns:
      row
[-1].update(_class = 'button btn btn-danger')

But when I am changing a table link in a smartgrid there needs to be extra code to change the table link in the grid and in any forms which are created by it.

It could be something like this:
delBtns = grid.elements('a', _name = deleteBtn)
if delBtns:
   
for delBtn.update(_class = 'button btn btn-danger')

and then whenever this button is being used by the grid / forms etc it will appear correctly. Also highlighting a specific button becomes easier. Select TR by id and button by name.

names for the table links could be:
if multi_links:
    name = [tablename]_[fieldname] + 'Btn'
else:
    name = [tablename] + 'Btn'

the other grid button names, I think, should hold roughly with the function argument names that control them.
'createBtn', 'detailsBtn', 'editBtn'
Reply all
Reply to author
Forward
0 new messages