Re: [web2py] SQLForm.grid - How do I use it properly?
try this : ,links = [lambda row: A( SPAN(_class='icon magnifier') ,'View Post' ,_class='button',_title='View Post' ,_href=URL(args=["view", db.person, row.id]) ) ] On Monday, November 21, 2011, Rahul wrote: > Hi Johann, > That is correct but I just wanted to know if I can change the > existing functionality for SQLForm.grid View button. To be precise - > here is an example of what I am trying to do. > > Example: > The default builtin "View" button on SQLForm.grid has label "View", > now how can I change its label to say "View Post". Note, here I do not > intend to over-ride the existing controller(function) that > SQLForm.grid's View provides but just change its label. How can we > achieve this? I hope you get what I am doing here :) > > Again - If someone could post the complete syntax for SQLForm.grid(All > possible parameters ). It would be really helpful. Thanks > > Thanks and Regards, Rahul > (www.flockbird.com - web2py powered) > > On Nov 19, 2:13 am, Johann Spies > > wrote: > > On 18 November 2011 09:00, Rahul > > wrote: > > > > > Hi Johan, All, > > >Sorry but I am not able to get it. With your code above I get > > > an invalid controller > > > > You are not supposed to use that code exactly as it is. You must adapt > it > > for your circumstances: > > > > > > links = [lambda row: > > > A('Edit',_href=URL("controller","edit",args=["update", tablename, a.id > ])) > > > > Replace "controller" with your controller e.g. 'default' > > Replace 'edit' with your function in the controller referred to. > > > > Regards > > Johann > > -- > > Because experiencing your loyal love is better than life itself, > > my lips will praise you. (Psalm 63:3) >
Re: [web2py] SQLForm.grid - How do I use it properly?
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 check
Re: [web2py] SQLForm.grid - How do I use it properly?
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
Re: [web2py] SQLForm.grid - How do I use it properly?
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
[web2py] SQLForm.grid - How do I use it properly?
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