Hi All,
         Thanks for your help and wonderful posts - I cleared the css
mess and I was able to see the SQLForm.grid properly. I tried working
with multiple and even updated plugin layouts but it does not display
the SQLForm.grid properly if I have a plugin_layouts thing. With
default scaffolding application, it works like a charm- Here are my
findings - Created a new application.

Jim - If I use fields=fields , I get below traceback (Note
columns=fields works fine) - have a look at code listing below -
[Note: this is in index() function ]

---
    query = ((db.projects_posts.post_visibility=="Classified"))
    fields = ('projects_posts.title',
               'projects_posts.project_details',
               'projects_posts.estimated_worth'
              )
    headers ={'projects_posts.title': 'Title',
              'projects_posts.project_details': 'Details',
              'projects_posts.estimated_worth': 'Worth'}

    ##columns=fields works, but fields=fields throws a ticket ..see
below
    form = SQLFORM.grid( query=query, columns=fields, headers=headers,
                         deletable=False, editable=False, csv=False,
maxtextlength=64, paginate=10 )

    return dict(form=form)
-------------------------------------
TRACEBACK
-------------------------------------

Traceback (most recent call last):
  File "D:\WEB2PY\web2py\gluon\restricted.py", line 194, in restricted
    exec ccode in environment
  File "D:/WEB2PY/web2py/applications/Link_IT/controllers/default.py",
line 162, in <module>
  File "D:\WEB2PY\web2py\gluon\globals.py", line 149, in <lambda>
    self._caller = lambda f: f()
  File "D:/WEB2PY/web2py/applications/Link_IT/controllers/default.py",
line 40, in index
    deletable=False, editable=False, csv=False, maxtextlength=64,
paginate=10 )
  File "D:\WEB2PY\web2py\gluon\sqlhtml.py", line 1588, in grid
    if not field.readable: continue
AttributeError: 'str' object has no attribute 'readable'

Now some questions -
Q1 - By links above, I meant - the add, delete, edit and view buttons
that are on the SQLForm.grid - Is there a way to add custom code for
it? With my new application, it works out of the box though and it
requires me to login.
Q2 - Can I use those button functions  without authorization?
Q3 - Is there a way to format the View rendered by the grid? Since the
"text" datatype field of Database containing huge text goes out of the
layout. It expands it horizontally.
Q4 - How can I hide ID field from showing up while viewing or
modifying data ?

Please excuse me for asking so many questions but this is the best
place to get the answers. Please let me know on above questions. I
also intend to put up a web2pyslice for SQLForm.grid once I am done
with it completely. Thanks

More questions to follow...

Thanks and Sincerely, Rahul
(www.flockbird.com - web2py powered)


------------------------------------------------------------------------------------
On Nov 15, 5:28 am, Massimo Di Pierro <massimo.dipie...@gmail.com>
wrote:
> true. fields should also work with expressions
> db.table.field1*db.table.field2+1 although I did not try.
>
> On Nov 14, 3:36 pm, JaapP <j...@tetra.nl> wrote:
>
>
>
>
>
>
>
> > One more reason to stick to using fields could be that with fields you
> > can specify the order in which the columns are shown, this didn't work
> > for 'columns'
>
> > On 14 nov, 18:13, Jim Steil <j...@qlf.com> wrote:
>
> > > Ok, columns are gone again...
>
> > > Might just be best to stick with using fields.
>
> > >      -Jim
>
> > > On 11/14/2011 8:47 AM, Jim Steil wrote:
>
> > > > I stand corrected on the 'columns' comment.  Massimo added it back in
> > > > this morning.
>
> > > >     -Jim
>
> > > > On 11/14/2011 8:45 AM, Jim Steil wrote:
> > > >> here are a few thoughts...
>
> > > >> 1.  Make sure you create this test in a new app.  If you're updating
> > > >> or adding functionality to an already existing app, then your layout
> > > >> and base.css need to be updated.
> > > >> 2.  If using jquery-ui, then you need to download jquery-ui and
> > > >> include it in your layout.html with a line like this:
>
> > > >> {{response.files.append(URL('static','jquery-ui/js/jquery-ui-1.8.16.custom.
> > > >>  min.js'))}}
>
> > > >> {{response.files.append(URL('static','jquery-ui/css/sunny/jquery-ui-1.8.16.
> > > >>  custom.css'))}}
>
> > > >> 3.  Don't use the 'columns' argument.  It is going away in the next
> > > >> release.  Instead, use 'fields'.  In your case, use the following:
>
> > > >> fields = [db.projects_posts.title, db.projects_posts.project_details,
> > > >> db.projects_posts.estimated_worth]
>
> > > >> 4.  I typically do not specify the 'headers' arg.  Instead, set the
> > > >> 'label' on your table definition.  That way you only have to do it
> > > >> once and can use it all over.  If you need to override it for a
> > > >> particular function, then just set the 'label' attribute in that
> > > >> function.
>
> > > >> 5.  At this time there is no documentation available for SQLFORM.grid
> > > >> or SQLFORM.smartgrid.  The best thing to do would be to look through
> > > >> this group for all the posts.  Massimo is working on an updated
> > > >> version of that manual that he is hoping to have complete by the end
> > > >> of this month.  That should contain information on .grid and 
> > > >> .smartgrid.
>
> > > >> 6.  If you are going to be playing around with this I would recommend
> > > >> that you work with the code in trunk.  I don't recall what state the
> > > >> .grid was in when 1.99.2 was released.
>
> > > >> As for answers for your specific questions:
>
> > > >> Q: What is the exact proper method to use SQLForm.grid -
> > > >> I think your on the right track.  Just need to clean up your css and
> > > >> layout.html files to get the proper formatting.
>
> > > >> Q: What all libraries do I need to include? where?
> > > >> If you want to use jquery-ui then you need to download it and
> > > >> reference it in your layout.html.
>
> > > >> Q: How to make links work the way they should ?
> > > >> I'd like some more information on what is going on here before giving
> > > >> an answer.
>
> > > >> Q: Can search be customized? How?
> > > >> I don't remember if the search_form is implemented in 1.99.2, but
> > > >> there is a search facility built in that allows the users to create a
> > > >> custom search.  I am not a fan of it and have some other ideas how
> > > >> developers could be allowed to create custom search forms, but I
> > > >> haven't opened a ticket on it yet.
>
> > > >> Q: Is this documented in online book?  - did not find much about it in
> > > >> version 3.2 though.
>
> > > >> Documentation will be coming with the next version of the book
> > > >> targeted for the end of the month.
>
> > > >> Hope this helps.
>
> > > >>     -Jim
>
> > > >> On 11/14/2011 6:54 AM, Rahul wrote:
> > > >>> Hi All,
> > > >>>        Can anyone let me know how to use SQLForm.grid properly or tell
> > > >>> me what I am missing. I have not installed any jquery plugin for the
> > > >>> same (assuming that it is part of 1.99.2 by default). I cannot see the
> > > >>> complete grid, just some buttons and data as per my query below. Also
> > > >>> the links do not function when clicked. The table does not show any
> > > >>> backgroud color or anything. Simply it doesnt look like a jquery
> > > >>> grid.  My code is as below -
>
> > > >>> My machine - Windows7 , IE9 and Firefox 7.0, Chrome.
> > > >>> Web2py- Latest stable (1.99.1)
>
> > > >>> #---------Controller- (default.py)---
> > > >>> def index():
> > > >>>      """
> > > >>>      example action using the internationalization operator T and 
> > > >>> flash
> > > >>>      rendered by views/default/index.html or views/generic.html
> > > >>>      """
> > > >>>      #Posts grid - SQLForm.grid
> > > >>>      #grid = SQLFORM.grid(db.projects_posts)
> > > >>>      query = ((db.projects_posts.post_visibility=="Classified"))
> > > >>>      columns = ('projects_posts.title',
> > > >>>                 'projects_posts.project_details',
> > > >>>                 'projects_posts.estimated_worth'
> > > >>>                )
> > > >>>      headers ={'projects_posts.title': 'Title',
> > > >>>                'projects_posts.project_details': 'Details',
> > > >>>                'projects_posts.estimated_worth': 'Worth'}
>
> > > >>>      form = SQLFORM.grid( query=query, columns=columns,
> > > >>> headers=headers,
> > > >>>                           deletable=False, editable=False, csv=False,
> > > >>> maxtextlength=64 )
>
> > > >>>      return dict(form=form)
>
> > > >>> #--------- View ---  (index.html)
> > > >>> {{extend 'layout.html'}}
> > > >>> {{=form}}
>
> > > >>> Also, if possible please refer me to the proper documentation for
> > > >>> SQLForm.grid. Again, if I include the parameter  form =
> > > >>> SQLForm.grid(.....,  ui="jquery-ui") in above code, the buttons
> > > >>> disappear and it only shows me links for 'view' etc.
>
> > > >>> Q: What is the exact proper method to use SQLForm.grid -
> > > >>> Q: What all libraries do I need to include? where?
> > > >>> Q: How to make links work the way they should ?
> > > >>> Q: Can search be customized? How?
> > > >>> Q: Is this documented in online book?  - did not find much about it in
> > > >>> version 3.2 though.
>
> > > >>> Please advice or refer me to the proper thread(though I checked
> > > >>> several to find solutions).
>
> > > >>> Regards, Rahul (www.flockbird.com - web2py powered)

Reply via email to