Hell I changed to SQLFORM.grid.
It kind of works now. I even managed to include status as drop down in my edit view. I created a left join on my status table. The problem I am facing now is that when a user selects a status for worker and clicks submit I get an error. looks like it is trying to insert a value for worker.w_status filed that does not exist in status table. How come? I mean it reads them from status table? What am I missing?? thank you My pseudocode query = ((db.worker.w_organisation == 10)) #Define the fields to show on grid. Note: (you need to specify id field in fields section in 1.99.2 fields = (db.worker.id, db.worker.w_first_name, db.worker.w_last_name, db.status.s_code, db.worker.w_nick_name, db.worker.w_email, db.worker.w_note) #Define headers as tuples/dictionaries # headers = {'worker.id' : 'Id', # 'worker.w_first_name' : 'Ime', # 'worker.w_last_name' : 'Priimek', # 'status.s_code' : 'Status', # 'worker.w_nick_name' : 'Vzdevek', # 'worker.w_email' : 'E-posta', # 'worker.w_note' : 'Komentar' } # #Let's specify a default sort order on date_of_birth column in grid default_sort_order=[db.worker.w_last_name] db.worker.w_organisation.readable = False db.worker.w_user.readable = False db.worker.w_organisation.editable = False db.worker.w_user.editable = False #Nardiš polje bl text like :) WIU WIU db.worker.w_first_name.widget = SQLFORM.widgets.string.widget #Validators * db.worker.w_status.requires = IS_IN_DB(db,db.status.s_code) # This created drop down but does not insert the right value into field* db.worker.w_first_name.requires = [IS_NOT_EMPTY(error_message='Obvezen vnos imena')] db.worker.w_email.requires = IS_EMAIL(error_message='Nepravilen e-mail') form = SQLFORM.grid(query=query, left=db.status.on(db.worker.w_status == db.status.id), fields=fields, searchable=True, orderby=default_sort_order,create=True, deletable=True, editable=True, paginate=25) 2014-07-16 15:18 GMT+02:00 Anthony <abasta...@gmail.com>: > workers = db(db.worker.w_organisation == 10).select(db.worker.w_id_w, >> db.worker.w_organisation, db.worker.w_first_name, db.worker.w_last_name,db. >> worker.w_nick_name,db.worker.w_email,db.worker.w_status,db. >> worker.w_note).as_list() >> > > What is the above for? It is not used below. > > >> #Define the query object. Here we are pulling all contacts having date of >> birth less than 18 Nov 1990 >> query = ((db.worker.w_organisation == 10) )#& (db.worker.w_status==db. >> status.s_id_s)) >> > > Why are you defining this query? Based on your model, looks like > db.status.s_id_s should just be db.status.id. Also, not clear how this > query selects based on birth date. > > >> fields = (db.worker.w_id_w,db.worker.w_first_name, >> db.worker.w_last_name,db.worker.w_nick_name,db.worker.w_email >> *,db.status.s_code*,db.worker.w_note) >> > > Note, smartgrid is for browsing one table at a time (and linking to > referencing tables), so you do not include fields from multiple tables in > the same grid. According to the book: > > > *A SQLFORM.smartgrid looks a lot like a grid, in fact it contains a grid > but it is designed to take as input not a query but only one table and to > browse said table and selected referencing tables.* > > If you want to include some extra columns, you can do so via the "links" > argument, which can be a dict with table names as the keys so you can > specify different links for each table. > > form = SQLFORM.smartgrid(db.worker,fields = fields,headers= >> headers,linked_tables=['status']) >> > > Note, db.status is not a child of db.worker -- it's the opposite -- there > is a one-to-many relationship from db.status to db.worker. So, specifying > linked_tables=['status'] will have no effect. On the other hand, if you do > SQLFORM.smartgrid(db.status, linked_tables=['worker']), each row of the > status grid will include a column with a "Workers" link to display a grid > of the workers associated with a given 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 a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/web2py/6xckg0C7Nb4/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Lep pozdrav Vid Ogris -- 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.