Skip to content

Commit

Permalink
max lengths custom option
Browse files Browse the repository at this point in the history
  • Loading branch information
rif committed Sep 18, 2012
1 parent bca8751 commit 4b77d37
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ plugins.web2admin.headers is a dictionary that maps 'tablename.fieldname' into t
plugins.web2admin.orderby is a dictionary that is used to set the default ordering for the table rows:

plugins.web2admin.orderby = {'student': db.student.last_name}

plugins.web2admin.maxtextlength sets the maximum length of text to be displayed for each field value, in the grid view (default 20). This value can be overwritten for each field using plugins.web2admin.maxtextlengths, a dictionary of 'tablename.fieldname':length. If text must be truncated then an extra len('...') = 3 is substracted from the specified length.

plugins.web2admin.maxtextlength ={'student': 10}
plugins.web2admin.maxtextlengths ={'test.name': 5}

### Multi-database support

Expand Down
5 changes: 3 additions & 2 deletions controllers/plugin_web2admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ def view_table():
onupdate = lambda form: history_callback(table, form, 'updated'),
ondelete = lambda table, record_id: history_callback(table, record_id, 'deleted'),
headers = plugins.web2admin.headers,
orderby = plugins.web2admin.orderby.get(table)

orderby = plugins.web2admin.orderby.get(table),
maxtextlength = plugins.web2admin.maxtextlength.get(table) or 20,
maxtextlengths = plugins.web2admin.maxtextlengths,
)
return locals()

Expand Down
2 changes: 2 additions & 0 deletions models/plugin_web2admin/plugin_web2admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def clone_action(table, ids):
headers = {},
orderby = {},
left = {},
maxtextlength = {},
maxtextlengths = {},
)
plugins.web2admin.actions.update(plugins.web2admin.default_actions)

Expand Down

0 comments on commit 4b77d37

Please sign in to comment.