[web2py] Re: Web2py grid shows key from IS_IN_SET({key: value}) model

2014-06-12 Thread Anthony
On Wednesday, June 11, 2014 3:48:15 PM UTC-4, 黄祥 wrote:

 Hi, Anthony, is it possible to combine the represent for change the color 
 depend on the value with the represent for is_in_set translate above?
 e.g.


Sure, instead of SPAN(status, ...) do SPAN(mydict[status], ...).

Anthony

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py grid shows key from IS_IN_SET({key: value}) model

2014-06-12 Thread 黄祥
it works, thank you so much, anthony
e.g.
product_status = {'On Sale': T('On Sale'), 'Hold': T('Hold'), 'Sold': 
T('Sold')}

table.status.represent = lambda status, field: SPAN(product_status[status], 
_class = 'text-success' if status == 'Sold' else 'text-warning' if status 
== 'Hold' else 'text-error')
table.status.requires = IS_IN_SET([('On Sale', T('On Sale') ), ('Hold', 
T('Hold') ), ('Sold', T('Sold') ) ] )

best regards,
stifan

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py grid shows key from IS_IN_SET({key: value}) model

2014-06-11 Thread Anthony
The IS_IN_SET validator affects form widgets but not other displays of the 
values in the field. If you want to change the way a value is displayed in 
a grid (or SQLTABLE), you must use the represent attribute of the field.

Anthony

On Wednesday, June 11, 2014 8:58:54 AM UTC-4, Stefan van den Eertwegh wrote:

 Hi all,

 I have a model where a Field has IS_IN_SET({'1':T(''),2:T('')}).

 When you have a grid in web2py; When you edit the record you see the value 
 (the translatable string).
 But when you view the record you see the key of the IS_IN_SET.

 IS is possible to have the grid showing the value from the IS_IN_SET in 
 the view?

 Thank you!


-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py grid shows key from IS_IN_SET({key: value}) model

2014-06-11 Thread Stefan van den Eertwegh
Hi Anthony,

Me and my colleges tried it with represent but we cant figure it out.
Can you give an example how this should work?
The table and column is templates.type (key: value)

Regards,
Stefan van den Eertwegh

Op woensdag 11 juni 2014 16:37:13 UTC+2 schreef Anthony:

 The IS_IN_SET validator affects form widgets but not other displays of the 
 values in the field. If you want to change the way a value is displayed in 
 a grid (or SQLTABLE), you must use the represent attribute of the field.

 Anthony

 On Wednesday, June 11, 2014 8:58:54 AM UTC-4, Stefan van den Eertwegh 
 wrote:

 Hi all,

 I have a model where a Field has IS_IN_SET({'1':T(''),2:T('')}).

 When you have a grid in web2py; When you edit the record you see the 
 value (the translatable string).
 But when you view the record you see the key of the IS_IN_SET.

 IS is possible to have the grid showing the value from the IS_IN_SET in 
 the view?

 Thank you!



-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py grid shows key from IS_IN_SET({key: value}) model

2014-06-11 Thread Anthony
mydict = dict(1=T(''), 2=T(''))

db.define_table('mytable',
Field('myfield', represent=lambda v, r: mydict[v]))

Anthony

On Wednesday, June 11, 2014 10:50:06 AM UTC-4, Stefan van den Eertwegh 
wrote:

 Hi Anthony,

 Me and my colleges tried it with represent but we cant figure it out.
 Can you give an example how this should work?
 The table and column is templates.type (key: value)

 Regards,
 Stefan van den Eertwegh

 Op woensdag 11 juni 2014 16:37:13 UTC+2 schreef Anthony:

 The IS_IN_SET validator affects form widgets but not other displays of 
 the values in the field. If you want to change the way a value is displayed 
 in a grid (or SQLTABLE), you must use the represent attribute of the 
 field.

 Anthony

 On Wednesday, June 11, 2014 8:58:54 AM UTC-4, Stefan van den Eertwegh 
 wrote:

 Hi all,

 I have a model where a Field has IS_IN_SET({'1':T(''),2:T('')}).

 When you have a grid in web2py; When you edit the record you see the 
 value (the translatable string).
 But when you view the record you see the key of the IS_IN_SET.

 IS is possible to have the grid showing the value from the IS_IN_SET in 
 the view?

 Thank you!



-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py grid shows key from IS_IN_SET({key: value}) model

2014-06-11 Thread Stefan van den Eertwegh
Hi Anthony,

I am sorry but it doesnt work.
Also gives pycharm an error at the rule mydict = dict

Stefan

Op woensdag 11 juni 2014 17:06:06 UTC+2 schreef Anthony:

 mydict = dict(1=T(''), 2=T(''))

 db.define_table('mytable',
 Field('myfield', represent=lambda v, r: mydict[v]))

 Anthony

 On Wednesday, June 11, 2014 10:50:06 AM UTC-4, Stefan van den Eertwegh 
 wrote:

 Hi Anthony,

 Me and my colleges tried it with represent but we cant figure it out.
 Can you give an example how this should work?
 The table and column is templates.type (key: value)

 Regards,
 Stefan van den Eertwegh

 Op woensdag 11 juni 2014 16:37:13 UTC+2 schreef Anthony:

 The IS_IN_SET validator affects form widgets but not other displays of 
 the values in the field. If you want to change the way a value is displayed 
 in a grid (or SQLTABLE), you must use the represent attribute of the 
 field.

 Anthony

 On Wednesday, June 11, 2014 8:58:54 AM UTC-4, Stefan van den Eertwegh 
 wrote:

 Hi all,

 I have a model where a Field has IS_IN_SET({'1':T(''),2:T('')}).

 When you have a grid in web2py; When you edit the record you see the 
 value (the translatable string).
 But when you view the record you see the key of the IS_IN_SET.

 IS is possible to have the grid showing the value from the IS_IN_SET in 
 the view?

 Thank you!



-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py grid shows key from IS_IN_SET({key: value}) model

2014-06-11 Thread Anthony
Sorry, do it this way:

mydict = {1: T(''), 2: T('')}

Anthony

On Wednesday, June 11, 2014 11:24:34 AM UTC-4, Stefan van den Eertwegh 
wrote:

 Hi Anthony,

 I am sorry but it doesnt work.
 Also gives pycharm an error at the rule mydict = dict

 Stefan

 Op woensdag 11 juni 2014 17:06:06 UTC+2 schreef Anthony:

 mydict = dict(1=T(''), 2=T(''))

 db.define_table('mytable',
 Field('myfield', represent=lambda v, r: mydict[v]))

 Anthony

 On Wednesday, June 11, 2014 10:50:06 AM UTC-4, Stefan van den Eertwegh 
 wrote:

 Hi Anthony,

 Me and my colleges tried it with represent but we cant figure it out.
 Can you give an example how this should work?
 The table and column is templates.type (key: value)

 Regards,
 Stefan van den Eertwegh

 Op woensdag 11 juni 2014 16:37:13 UTC+2 schreef Anthony:

 The IS_IN_SET validator affects form widgets but not other displays of 
 the values in the field. If you want to change the way a value is 
 displayed 
 in a grid (or SQLTABLE), you must use the represent attribute of the 
 field.

 Anthony

 On Wednesday, June 11, 2014 8:58:54 AM UTC-4, Stefan van den Eertwegh 
 wrote:

 Hi all,

 I have a model where a Field has IS_IN_SET({'1':T(''),2:T('')}).

 When you have a grid in web2py; When you edit the record you see the 
 value (the translatable string).
 But when you view the record you see the key of the IS_IN_SET.

 IS is possible to have the grid showing the value from the IS_IN_SET 
 in the view?

 Thank you!



-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py grid shows key from IS_IN_SET({key: value}) model

2014-06-11 Thread 黄祥
Hi, Anthony, is it possible to combine the represent for change the color 
depend on the value with the represent for is_in_set translate above?
e.g.
table.status.represent = lambda status, field: SPAN(status, _class = 
'text-success' if status == 'Sold' else 'text-warning' if status == 'Hold' 
else 'text-error')
table.status.requires = IS_IN_SET([('On Sale', T('On Sale') ), ('Hold', 
T('Hold') ), ('Sold', T('Sold') ) ] )

thanks and best regards,
stifan

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.