Many-to-Many widgets

8 views
Skip to first unread message

Fran

unread,
Dec 29, 2008, 3:39:46 PM12/29/08
to web2py Web Framework
I agree with this thread that a good method for handling the 80% case
where the Many-to-Many just has the mapping fields would be really
useful:
http://groups.google.com/group/web2py/browse_thread/thread/70273ee7ba826a59/6393c3d67380a8ff

Massimo, I know that you're not much into including this in SQLFORM
(since 20% of the time people wish to store extra fields in the M2M
table such as 'Quantity'), but for me this would be really useful.

I guess the implementation would end up looking something like this:
http://code.google.com/p/django-ajax-filtered-fields/
Another option is the one previously mentioned:
http://marinhobrandao.com/blog/p/ajax-many2manyfield-widget-screenshot_152/
(from
http://translate.google.com/translate?hl=en&u=http%3A%2F%2Fmarinhobrandao.com%2Fblog%2Fp%2Fajax-manytomanyfield-widget%2F&sl=pt&tl=en&swap=1)

Does anyone have samples of work they've done on this?
- ideally by extending SQLFORM (or t2.create() / t2.update()) but even
manual HTML examples would be great
- code ideal but even screenshots or a demo app to play with to se how
it should look would be useful

For me, I'm more interested in UUID links than ID ones, so an
implementation that handles that nicely would be perfect :)

Many thanks,
Fran.

vince

unread,
Dec 30, 2008, 12:59:39 AM12/30/08
to web2py Web Framework
http://groups.google.com/group/web2py/browse_thread/thread/29655ebffb97d7ac/c8dcc5e5ed3c7ea5

this is a simple one. maybe you can base on this widget and workout
something.

-vince

On Dec 30, 4:39 am, Fran <francisb...@googlemail.com> wrote:
> I agree with this thread that a good method for handling the 80% case
> where the Many-to-Many just has the mapping fields would be really
> useful:http://groups.google.com/group/web2py/browse_thread/thread/70273ee7ba...
>
> Massimo, I know that you're not much into including this in SQLFORM
> (since 20% of the time people wish to store extra fields in the M2M
> table such as 'Quantity'), but for me this would be really useful.
>
> I guess the implementation would end up looking something like this:http://code.google.com/p/django-ajax-filtered-fields/
> Another option is the one previously mentioned:http://marinhobrandao.com/blog/p/ajax-many2manyfield-widget-screensho...
> (fromhttp://translate.google.com/translate?hl=en&u=http%3A%2F%2Fmarinhobra...)

Fran

unread,
Dec 30, 2008, 6:43:44 AM12/30/08
to web2py Web Framework
On Dec 30, 5:59 am, vince <lapcc...@gmail.com> wrote:
> http://groups.google.com/group/web2py/browse_thread/thread/29655ebffb...
> this is a simple one. maybe you can base on this widget and workout
> something.

t2.widget() is indeed a nice, simple UI to look at borrowing from.
This uses a single text field to store entries rather than a Many-to-
Many field, so I guess performance will get bad when storing lots of
entries?
I'll also need to be able to select from potentially hundreds of
options, so the solution isn't scalable as-is...I think I want to be
able to select the options from the output of a t2.search() &/or an
AutoComplete.

Anyway, I'll look at that code & see if it can be used as a starting
point :)

F

Fran

unread,
Dec 30, 2008, 8:47:45 AM12/30/08
to web2py Web Framework
> t2.widget()

t2.tag_widget() of course ;)

Another issue with using this widget as-is would be referential
integrity - need to ensure that all lists are updated if 'tags' are
deleted (not generally an issue for real tags, but is for when trying
to squeeze m2m functionality into here)

F

Fran

unread,
Dec 30, 2008, 9:17:06 AM12/30/08
to web2py Web Framework
& another limitation ;)

I need to be able to store both UUI & Name.
t2.tag_widget() can't store dicts, only lists...

F

vince

unread,
Dec 30, 2008, 11:48:34 AM12/30/08
to web2py Web Framework
oh actually i haven't look t2's widget yet. i'll have a look

i will need to sort out a widget for m2m using multiple select box too
soon. i'll post it here if i come up with anything.
i had an implement for below 50 options using a single text field
holding the id in csv. that's no good for you if you're looking for
hundreds of entries

-vinc

mdipierro

unread,
Dec 30, 2008, 2:05:18 PM12/30/08
to web2py Web Framework
I will soon release an improved version. Possibly tomorrow.

Massimo
Reply all
Reply to author
Forward
0 new messages