I'm trying to learn more about LOAD and ajax.

I have an SQLFORM.grid loaded as a component. It's read only.
I've added a button to each row using 
links = [lambda row: INPUT(_name='toggle',_type="submit",_value="Toggle",
                                _onclick="ajax('toggle_order_import_v2',['id'] 
,':eval')")])


Each row of the grid indeed has the record ID in a column called ID. The 
"toggle" flips a boolean field.

The generated HTML looks fine: this is the button

<input type="submit" value="Toggle" onclick="ajax('toggle_order_import_v2',[
'id'] ,':eval')" name="toggle">

the function toggle_order_import_v2() is in my controller.
it updates the database, so I want to refresh the LOADed sqlform.grid with 
the returned ':eval' JavaScript... I haven't got to that yet.

The called function first does
id = request.vars.id
as preparation for updating the record matchting the grid row.

but via the debugger I see that this is evaluating as None, which surprises 
me; I expect the ID of the row.

I see there are some threads on action buttons using the A helper but I was 
hoping to learn how to use the ajax function, which sounds like it should 
work in this situation.

(My legacy code does not use LOAD and the button uses a A tag; the legacy 
'toggle' controller updates the database and then uses redirect to reload 
the page. It works, but it's slow (and worse, user filters applied to the 
grid are reset)
When I put the SQLFORM.grid in a component but keep the legacy 'toggle' 
code, the redirect breaks, which is why I want to go 100% AJAX)





-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to