[web2py] Re: SQLFORM.grid to update page
Yes, REST is definitely simpler. I'm not too familiar with JavaScript. Let me explain what I'm trying to do... I have two SQLFORM.grids on the same page. The user clicks on one row of one grid to add that row to the other grid. A simple enough application pattern. Just like when you click on delete to delete a row from a grid and the grid automatically updates on the page, I want something similar to occur here. Now, this works fine as far as it goes using links and REST. However, if the first grid has pagination and you're on, say, the third page, I'd like to preserve my place (ie, stay on page 3) when the page is updated. It's not a big deal, I guess. The user will have to manually go back to where he was before. On Sunday, 2 March 2014 01:41:31 UTC-5, Tim Richardson wrote: I'm probably not following you, but if you want the server to do something resulting in new content on the page, you either instigate a new request via a URL (which I think is known as the REST method), or use AJAX to fetch data from the server (and then use javascript to update part of the page). the links method that you have above is a REST approach. It has to create a request and a page reload, that's the way it works. Using AJAX is easy with web2py, see the chapter on AJAX and perhaps the following chapter on components. In this case the action on your link can not be a URL since this makes a request page load. You would execute javascript instead. REST is simpler I think. AJAX is a smoother user experience (there is no page reload, for example). On Sunday, 2 March 2014 03:34:41 UTC+11, horridohobbyist wrote: Okay, then, I see another issue... Right now, I'm trying to execute the function by using a link: links=[lambda row: A('Add',_href=URL('add',args=[db.videos,row.id ,user_id]))], But this means a new request in the Add function. I really should execute a function *in-place* on the current webpage. How do I do that? Thanks. On Saturday, 1 March 2014 08:30:33 UTC-5, Anthony wrote: Notice in Tim's example, vars is an argument of URL(). On Saturday, March 1, 2014 7:40:36 AM UTC-5, horridohobbyist wrote: type 'exceptions.TypeError' redirect() got an unexpected keyword argument 'vars' On Friday, 28 February 2014 18:34:54 UTC-5, Tim Richardson wrote: In my slice on inline-editable grid ( http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript ) I do this to reload redirect(URL('default','editable_grid',vars=request._get_vars)), ) #preserving _get_vars means user goes back to same grid page, same sort options etc On Saturday, 1 March 2014 04:28:59 UTC+11, horridohobbyist wrote: I have a SQLFORM.grid and I would like to add a link or function to each row that will do something and immediately refresh/update the webpage. Is this possible? Thanks. -- 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/groups/opt_out.
[web2py] Re: SQLFORM.grid to update page
I think there's a warning in the book against two grids on the same page. I've never tried it due to the warning, but state of the grid is maintained via data passed back in the request. I think the grid code assumes that any grid state data passed back applies to it, so two grids may both assume they are the target of state information actually sourced from only one grid when it POSTs back updated state. Likely to be very confusing. Using components (LOAD) should work around that. Your application platform still needs to address the problem of communicating with the server. You either round trip with REST, which means page reloads, or you use javascript to get part of the page to reload (e.g. LOAD, see chapter on components, it's pretty clever) or you can use full AJAX. Using LOAD may mean a bit of javascript, mainly so that your LINK button requests the LOADed component to reload. It's a common use-case in web2py and you'll easily get help here. I think the book documentation is reasonably good. -- 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/groups/opt_out.
[web2py] Re: SQLFORM.grid to update page
Two grids in the same page are definitively not allowed unless loaded via Ajax. That is because they use the URL to transfer grid parameters and if you have two it is not clear which one applies to. On Sunday, 2 March 2014 14:45:37 UTC-6, Tim Richardson wrote: I think there's a warning in the book against two grids on the same page. I've never tried it due to the warning, but state of the grid is maintained via data passed back in the request. I think the grid code assumes that any grid state data passed back applies to it, so two grids may both assume they are the target of state information actually sourced from only one grid when it POSTs back updated state. Likely to be very confusing. Using components (LOAD) should work around that. Your application platform still needs to address the problem of communicating with the server. You either round trip with REST, which means page reloads, or you use javascript to get part of the page to reload (e.g. LOAD, see chapter on components, it's pretty clever) or you can use full AJAX. Using LOAD may mean a bit of javascript, mainly so that your LINK button requests the LOADed component to reload. It's a common use-case in web2py and you'll easily get help here. I think the book documentation is reasonably good. -- 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/groups/opt_out.
[web2py] Re: SQLFORM.grid to update page
type 'exceptions.TypeError' redirect() got an unexpected keyword argument 'vars' On Friday, 28 February 2014 18:34:54 UTC-5, Tim Richardson wrote: In my slice on inline-editable grid ( http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript ) I do this to reload redirect(URL('default','editable_grid',vars=request._get_vars)), ) #preserving _get_vars means user goes back to same grid page, same sort options etc On Saturday, 1 March 2014 04:28:59 UTC+11, horridohobbyist wrote: I have a SQLFORM.grid and I would like to add a link or function to each row that will do something and immediately refresh/update the webpage. Is this possible? Thanks. -- 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/groups/opt_out.
[web2py] Re: SQLFORM.grid to update page
Notice in Tim's example, vars is an argument of URL(). On Saturday, March 1, 2014 7:40:36 AM UTC-5, horridohobbyist wrote: type 'exceptions.TypeError' redirect() got an unexpected keyword argument 'vars' On Friday, 28 February 2014 18:34:54 UTC-5, Tim Richardson wrote: In my slice on inline-editable grid ( http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript ) I do this to reload redirect(URL('default','editable_grid',vars=request._get_vars)), ) #preserving _get_vars means user goes back to same grid page, same sort options etc On Saturday, 1 March 2014 04:28:59 UTC+11, horridohobbyist wrote: I have a SQLFORM.grid and I would like to add a link or function to each row that will do something and immediately refresh/update the webpage. Is this possible? Thanks. -- 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/groups/opt_out.
[web2py] Re: SQLFORM.grid to update page
Okay, then, I see another issue... Right now, I'm trying to execute the function by using a link: links=[lambda row: A('Add',_href=URL('add',args=[db.videos,row.id,user_id]))], But this means a new request in the Add function. I really should execute a function *in-place* on the current webpage. How do I do that? Thanks. On Saturday, 1 March 2014 08:30:33 UTC-5, Anthony wrote: Notice in Tim's example, vars is an argument of URL(). On Saturday, March 1, 2014 7:40:36 AM UTC-5, horridohobbyist wrote: type 'exceptions.TypeError' redirect() got an unexpected keyword argument 'vars' On Friday, 28 February 2014 18:34:54 UTC-5, Tim Richardson wrote: In my slice on inline-editable grid ( http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript ) I do this to reload redirect(URL('default','editable_grid',vars=request._get_vars)), ) #preserving _get_vars means user goes back to same grid page, same sort options etc On Saturday, 1 March 2014 04:28:59 UTC+11, horridohobbyist wrote: I have a SQLFORM.grid and I would like to add a link or function to each row that will do something and immediately refresh/update the webpage. Is this possible? Thanks. -- 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/groups/opt_out.
[web2py] Re: SQLFORM.grid to update page
I'm probably not following you, but if you want the server to do something resulting in new content on the page, you either instigate a new request via a URL (which I think is known as the REST method), or use AJAX to fetch data from the server (and then use javascript to update part of the page). the links method is a REST approach. It has to create a request and a page reload, that's the way it works. Using AJAX is easy with web2py, see the chapter on components. In this case the action on your link can not be a URL since this makes a request page load. You would execute javascript instead. REST is simpler I think. AJAX is a smoother user experience (there is no page reload, for example). On Sunday, 2 March 2014 03:34:41 UTC+11, horridohobbyist wrote: Okay, then, I see another issue... Right now, I'm trying to execute the function by using a link: links=[lambda row: A('Add',_href=URL('add',args=[db.videos,row.id ,user_id]))], But this means a new request in the Add function. I really should execute a function *in-place* on the current webpage. How do I do that? Thanks. On Saturday, 1 March 2014 08:30:33 UTC-5, Anthony wrote: Notice in Tim's example, vars is an argument of URL(). On Saturday, March 1, 2014 7:40:36 AM UTC-5, horridohobbyist wrote: type 'exceptions.TypeError' redirect() got an unexpected keyword argument 'vars' On Friday, 28 February 2014 18:34:54 UTC-5, Tim Richardson wrote: In my slice on inline-editable grid ( http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript ) I do this to reload redirect(URL('default','editable_grid',vars=request._get_vars)), ) #preserving _get_vars means user goes back to same grid page, same sort options etc On Saturday, 1 March 2014 04:28:59 UTC+11, horridohobbyist wrote: I have a SQLFORM.grid and I would like to add a link or function to each row that will do something and immediately refresh/update the webpage. Is this possible? Thanks. -- 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/groups/opt_out.
[web2py] Re: SQLFORM.grid to update page
In my slice on inline-editable grid (http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript) I do this to reload redirect(URL('default','editable_grid',vars=request._get_vars)), ) #preserving _get_vars means user goes back to same grid page, same sort options etc On Saturday, 1 March 2014 04:28:59 UTC+11, horridohobbyist wrote: I have a SQLFORM.grid and I would like to add a link or function to each row that will do something and immediately refresh/update the webpage. Is this possible? Thanks. -- 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/groups/opt_out.