Notice this demo (http://www.web2py.com/plugins) makes one sortable
list per user (identified by client) so you can test it without
affecting other users.

Rearrange the items as you like then reload the page and see they stay
sorted.

Here is the complete code excluding the plugin file itself:

Model:

db.define_table('fruit',Field('sortable','integer'),Field
('client'),Field('name'))

if not db(db.fruit.client==request.client).count():
    db.fruit.client.default=request.client
    db.fruit.insert(name='Apple')
    db.fruit.insert(name='Melon')
    db.fruit.insert(name='Banana')
    db.fruit.insert(name='Strawberry')
    db.fruit.insert(name='Raspberry')

Controller:

def index():
    return dict()
def sort():
    plugin_sortable_sort(db.fruit,query=
(db.fruit.client==request.client),sortable_field='sortable')

View index.html:

{{extend 'layout.html'}}
<style>
.sortable LI {
   width: 200px;
   background: orange;
   color: white;
   border: 2px solid white;
   padding: 5px 5px 5px 5px;
}
</style>
{{=plugin_sortable([(r.id,r.name) for r in db
(db.fruit.client==request.client).select
(orderby=db.fruit.sortable)],callback=URL(r=request,f='sort'))}}



On Jan 31, 9:51 am, weheh <[email protected]> wrote:
> Sounds great! Do you have an example online that we could look at?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to