OK, I don't like this but this is only way to do. I can look up the table 
in the view. What a mess....


<tr>
    <td class="w2p_fw"><label>Grade</label></td>
    <td class="w2p_fw" >: 
    {{grade = 
db.KR_GradeLabel(db.KR_GradeLabel.Name==form.custom.dspval.Grade)}}
        {{if grade:}}
    {{=grade.Label}}
        {{else:}}
        {{=form.custom.dspval.Grade}}
    {{pass}}</td>
</tr>

On Thursday, February 5, 2015 at 2:37:10 PM UTC-6, Omi Chiba wrote:
>
> Thank you for the reply. I'm not really sure how to use lamda. The problem 
> is IS_IN_DB doesn't work when it's readonly and I found requires only works 
> for Create/Edit and need to use represent for readonly view.
>
> I think this is a bug and should be it's already fixed but doen't matter 
> to me because I'm stuck in my web2py version.
>
> So I'm trying to rewrite 
>
> db.KR_Product.Grade.requires=IS_IN_DB(db,'KR_GradeLabel.Name','%(Label)s')
>
> for represent.
>
> I need to make this work.... 
>
> In worst case, I need to lookup this KR_GradeLabel table in view using the 
> value "P" and get the Label "P = Precision"....
>
>
> On Thursday, February 5, 2015 at 2:23:09 PM UTC-6, Richard wrote:
>>
>> Omi,
>>
>> In this : db.KR_Product.Grade.represent =  lambda Name: 
>> SPAN(db.KR_GradeLabel[Name].Label)
>>
>> I don't understand where you are going...
>>
>> You try to set a represent over table KR_Product for field Grade right?
>>
>> But you get you represent value from another table KR_GradeLabel...
>>
>> In case of a represent the lambda value is the field content for a given 
>> record... So you Name lambda passed variable may sure not containing what 
>> you think or want it contains... I don't see in your model definition that 
>> KR_Product.Grade to be actually a reference field... Model not saying so 
>> and field name neither...
>>
>> Richard
>>
>> On Thu, Feb 5, 2015 at 3:09 PM, Omi Chiba <[email protected]> wrote:
>>
>>> I'm using 2.4.7 released 2013.05.24 so it could be bug and fixed now but 
>>> I need to work on this version for now because I have issue with the latest 
>>> web2py. Anyway, I found this 
>>> https://groups.google.com/forum/#!searchin/web2py/IS_IN_DB$20readonly/web2py/uBBcvthCDl8/Z7s872JW47IJ
>>>
>>> and tried something 
>>>
>>> db.KR_Product.Grade.represent =  lambda Name: 
>>> SPAN(db.KR_GradeLabel[Name].Label)
>>>
>>> but I got a error says 
>>>
>>> <type 'exceptions.AttributeError'>('Table' object has no attribute 'P')
>>>
>>> Which P is the key value. And I want to shop P = Precision from another 
>>> table.
>>>
>>>
>>> On Thursday, February 5, 2015 at 1:48:48 PM UTC-6, Omi Chiba wrote:
>>>>
>>>> I tried edit mode and put the following script in the view which works 
>>>> but feels so stupid and user cannot copy the values which I have to allow 
>>>> them top copy and paste.
>>>>
>>>> <script>
>>>> jQuery(document).ready(function(){
>>>>    jQuery('#main').find('input, select').attr("readonly", true);
>>>> });
>>>> </script>
>>>>
>>>> On Thursday, February 5, 2015 at 11:22:49 AM UTC-6, Omi Chiba wrote:
>>>>>
>>>>> In another word, it shows fine when I use 
>>>>> {{=form.custom.widget.Grade}} with edit mode (   form = 
>>>>> SQLFORM(db.KR_Product,record, readonly=False)) but not when I do 
>>>>> readonly=True
>>>>>  
>>>>>
>>>>  -- 
>>> 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 [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to