uploading to trunk
On Dec 26, 11:42 am, Alexandre Andrade <[email protected]> wrote: > I could solve most of my problems using the new fantastic smartgrid. > > But i have 2 sugestions for the developers: > > in sqlhtml.py > > Line 1368 : > > from > _value="query",_type="button",_id="w2p_query_trigger", > > to: > > _value=T("query"),_type="button",_id="w2p_query_trigger", > > to allow i18n > > and > > line 1925: > > from > ' ', > > to: > ' > ', > > to correct separation between first and second steps > > Regards. > > Alexandre Andrade > > 2011/12/26 Alexandre Andrade <[email protected]> > > > > > > > > > > > Hi Jim, > > > Just to know your example of query worked to me. > > > Thanks again. > > > Alexandre Andrade > > > 2011/12/26 Alexandre Andrade <[email protected]> > > >> Hi Jim, > > >> Thanks for reply. > > >> 1. I will try your example of query/contraints. > >> 2. about represent/lambda issue: i get it working with a workaround, but > >> I think it could be easier. > >> 3. about linked_tables: it works with grid/list, but in view/edit it > >> shows all linked tables. I have some cases I dont want the user see all > >> linked tables, just one or two of them. > > >> Regards. > > >> 2011/12/26 Jim Steil <[email protected]> > > >>> I don't know why you're having the problems you are. > > >>> Regarding the lambda issue, I too have noticed the change, but thought > >>> it worked throughout web2py to always pass the row argument. However, I'm > >>> no longer using crud so I wouldn't notice that. > > >>> Linked tables are working for me. What do you mean when you say it > >>> doesn't work for view and edit? > > >>> Constraints has been working for me - here is a sample: > > >>> # Build query > >>> queries = [] > >>> constraints = None > >>> if searchText and searchText .strip() != '': > >>> queries.append(db.asset.description.contains(searchText)) > >>> if assetTypeId and assetTypeId > 0: > >>> queries.append(db.asset.assetTypeId==assetTypeId) > >>> if len(queries) > 0: > >>> query = reduce(lambda a,b:(a&b),queries) > >>> constraints={'asset':query} > > >>> # Setup search forms > >>> searchForms = {'asset':assetSearch} > > >>> grid = SQLFORM.smartgrid(db.asset, fields=fields, > >>> constraints=constraints, orderby=orderby, > >>> create=create, details=details, > >>> editable=editable, deletable=deletable, > >>> csv=False, > >>> search_widget={'asset':assetSearch}, > >>> searchable=True, > >>> paginate=15, maxtextlength=45) > > >>> All of these work ok for me. Possibly your use cases are different that > >>> mine. Could you share some detail about what you are seeing that isn't > >>> working for you? > > >>> -Jim > > >>> On 12/26/2011 8:23 AM, Alexandre Andrade wrote: > > >>> I'm trying to use smartgrid in a app, and could be sucessful in most > >>> parts. > >>> But there are some things stopping, so I'm here asking for help > > >>> 1. The old way of use lambda in represent was > > >>> represent = lambda field: get_atividade(field) > > >>> and now, in some parts of smartgrid and book V4, look as: > > >>> represent = lambda field,row : get_atividade(field) > > >>> the last works with the grid, but not in form to view and crud. > > >>> I solved this using a if statement, but I think that could be > >>> implemented one way to do use represent without setting it every time. > > >>> 2. The linked_tables settings works for grid, but not for form (view and > >>> edit) . I looked at code (gluon/sqlhtml.py#..smartgrid) > >>> , and found this: > > >>> if linked_tables is None or referee in linked_tables: > >>> field.represent = lambda > >>> id,r=None,referee=referee,rep=field.represent: A(callable(rep) and rep(id) > >>> or > >>> id,_class=trap_class(),_href=URL(args=request.args[:nargs]+['view',referee, > >>> id], > >>> user_signature=user_signature)) > > >>> i think referee is a way to know if is viewing or edit form, but it > >>> always show all the linked_tables, so linked_tables settings is uselless. > >>> I think it could remove the second part of if to properly use the settings > >>> way. > > >>> 3. I need to show only some registers in a grid. But whiles the docs > >>> talk about the constraints settings, i cant find a example of query to > >>> make > >>> it work. A workaround was use the keywords (as in user made query, but it > >>> has the disavantage of show the query in the search field. > >>> Could someone provide a example of using constraints? > > >>> -- > >>> Atenciosamente > > >>> Alexandre Andrade > >>> Hipercenter.com Classificados Gratuitos > > >> -- > >> Atenciosamente > > >> Alexandre Andrade > >> Hipercenter.com Classificados Gratuitos > > > -- > > Atenciosamente > > > Alexandre Andrade > > Hipercenter.com Classificados Gratuitos > > -- > Atenciosamente > > Alexandre Andrade > Hipercenter.com Classificados Gratuitos

