I am not familiar with how database reads arguments but try replace

href='{{=URL('Herramientas','usuarioUpdate',args=["users.id"])}}'

with

href='{{=URL('Herramientas','usuarioUpdate'}}/users.id'

because anything in between {{...}} is executed by the server before it 
gets to datatables.


Also

def usuarioUpdate():
       return dict(formUsuarioUpdate=crud.update(db.Users,request.args(0)))

should be

def usuarioUpdate():
       return 
db(db.Users.id==request.args(0,cast=int)).update(**request.post_vars)


With some fiddle around you can make this work.
You may also want to consisder using web2py' sqlform.grid or 
https://github.com/ratiw/vuetable-2-tutorial/wiki





On Monday, 15 April 2019 20:24:58 UTC-7, Cristina Sig wrote:
>
> Hello everybody,
>
> I'm trying to add an "Edit" and "Delete" buttons on each row on a 
> Datatable. When I click on "edit", it calls a controller function and needs 
> to pass the id of that row as argument. I'm having issues doing it right. 
> Any suggestions?
>
>
> Thank you!
>
>
> My controller
>
>
> def usuarioUpdate():
>        return dict(formUsuarioUpdate=crud.update(db.Users,request.args(0)))
>
>
> My view
>
>
>   <script>
>         var tabla;
>     $(document).ready(function(){
>            tabla=  $('#tablaGenerica').DataTable({
>                     "data":  {{=formListar}},
>                     "scrollX": false,
>                      "dom": 'lrtip',
>                      "searching": true,
>                      "sRowSelect": 'single',
>                      "language": {
>                      "url": "{{=URL('static','js/tradutorTable.json')}}",
>                     },
>                    "columns": [
>                                   {
>                                      "class":"details-control",
>                                      "orderable":false,
>                                      "data":null,
>                                      "defaultContent": ""
>                                   },
>                                   { data: 'users.first_name' },
>                                   { data: 'users.last_name' },
>                                   { data: 'users.email' },
>                                   { data: 'users.username' },
>                                   {
>                                      "orderable":false,
>                                      "data":null,
>                                      "defaultContent": "<div class='btn-group 
> btn-group-justified JpositionA'><a class='btn btn-success Jview btn-xs' 
> href='{{=URL('Herramientas','usuarioUpdate',args=["users.id"])}}'><span 
> class='glyphicon glyphicon-pencil'></span></a><a class='btn btn-warning Jview 
> btn-xs' href=><span class='glyphicon glyphicon-remove'></span></a></div>",
>                                   },
>                               ]
>                 });
>     </script>
>
> <table id="tablaGenerica" class="tablaC table-striped hover cell-border" 
> cellspacing="0" width="100%" >
> <thead>
>     <tr>
>         <th></th>
>         <th>Nombre</th>
>         <th>Apellido</th>
>         <th>Correo Electrónico</th>
>         <th>Nombre de Usuario</th>
>         <th></th>
>     </tr>
> </thead>
> </table>
>
>
>
>

-- 
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/d/optout.

Reply via email to