[web2py] Re: represented fields and jqgrid

2011-05-09 Thread niknok
pbreit, config is a Storage() object and member_status a Dictionary,
and the python get() function.

Ross, you're right. That's how I'm using it.  I went back to re-check
my definition file and everything appears to be in order. Note that
it's only in jqgrid that it's not showing up, it works correctly with
appadmin

In the model:
settings.member_status={
0:'Pending'
,2:'Blocked'
,4:'Verified'
}

...
Field('member_status','integer',default=0)
...
db.auth_user.member_status\
.requires=IS_IN_SET(settings.member_status,zero=None,sort=False)

If I don't define the representation, it doesn't use the hard coded
dictionary options. After I define the representation, it still
doesn't show up in jQuery.

I'm using version 1.94.6. What version are you using?

On May 6, 11:14 pm, Ross Peoples ross.peop...@gmail.com wrote:
 I had similar issues with computed fields. I don't know if this helps or
 not, but it looks like you are using member_status as a selection of hard
 coded options. This is what I do:

 db.member_statuses = {
   1: 'Active',
   2: 'Inactive',}

 db.define_table('auth_user_extended',
   Field('auth_user', db.auth_user),
   Field('member_status', 'int', requires=IS_IN_SET(db.member_statuses),
 default=1),
   ...
 )

 Then when the field is represented, it should use the values from dictionary
 ('Active' or 'Inactive') automatically without having to set represent. I
 hope this helps, as it's worked for me pretty well so far.


[web2py] Re: represented fields and jqgrid

2011-05-06 Thread niknok
bump...

Anyone?

On May 5, 8:27 am, niknok nikolai...@gmail.com wrote:
 I .represent a field as follows:

         db.auth_user.gender.represent=lambda i: db.aux_gender[i].concept[:1] 
 if i0 else '?'
         db.auth_user.member_status.represent=lambda i: 
 config.member_status.get(i)[:1] or '?'

 The first one works, and displays data in jqgrid as expected:'M','F'
 or'?'. The second only shows a blank cell in jqgrid.

 I tried a DAL select query and crud.search and the data is represented
 correctly.


[web2py] Re: represented fields and jqgrid

2011-05-06 Thread Ross Peoples
I had similar issues with computed fields. I don't know if this helps or 
not, but it looks like you are using member_status as a selection of hard 
coded options. This is what I do:

db.member_statuses = {
  1: 'Active',
  2: 'Inactive',
}
db.define_table('auth_user_extended',
  Field('auth_user', db.auth_user),
  Field('member_status', 'int', requires=IS_IN_SET(db.member_statuses), 
default=1),
  ...
)

Then when the field is represented, it should use the values from dictionary 
('Active' or 'Inactive') automatically without having to set represent. I 
hope this helps, as it's worked for me pretty well so far.


[web2py] Re: represented fields and jqgrid

2011-05-06 Thread pbreit
I'm not sure this is a valid function: config.member_status.get(i)

Where did you get that?