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.

Reply via email to