Hello

I am using datatables plugin to dynamically edit table of workers which are 
read from database

my code on client side is 

JAVASCRIPT
var getTableData = function (){
var table = $('#example').tableToJSON(), // Convert the table into a 
javascript object
datas = JSON.stringify(table);
 return datas;
};

var saveTableData = function(){
var tableData = getTableData();
$.ajax({
         type: 'POST',
         url: '{{=URL('script', 'saveWorkers.json')}}',
 data: {data : tableData},
 dataType: 'json',
     }).done(function( msg ) { });
 };

$(document).ready(function() {
var table = $('#example').dataTable();
saveTableData(); //Will be triggered on save button

 //Hide columns
$('#example tr *:nth-child(1)').css('display','none');
        $('#example tr *:nth-child(2)').css('display','none');
$('#example').editableTableWidget().numericInputExample().find('td:first').focus();
    
} );

HTML

<table id="example" class="table table-striped table-bordered display" 
cellspacing="0" width="100%">
       <thead>
            <tr>
             <th>Id</th>
                <th>Organizacija</th>
                <th>Ime</th>
                <th>Priimek</th>
                <th>Vzdevek</th>
                <th>E-mail</th>
                <th>Status</th>
                <th>Komentar</th>
            </tr>
        </thead>
        
        <tbody>
 {{for worker in workers:}}
<tr>
<td>{{=worker['w_id_w']}}</td>
<td>{{=worker['w_organisation']}}</td>
<td>{{=worker['w_first_name']}}</td>
<td>{{=worker['w_last_name']}}</td>
<td>{{=worker['w_nick_name']}}</td>
<td>{{=worker['w_email']}}</td>
<td>{{=worker['w_status']}}</td>
<td>{{=worker['w_note']}}</td>
</tr>
{{pass}} 
        </tbody>
    </table>


What is the best way to menage editing (update/delete/add) record(s). I 
have all workers in one table (also on view part) for fast and easy edit 
from client's part of view
Also I am experiencing problems with add new row to table and delete last 
row

First I would like to be saved/updated/deleted on button click but if not 
too complicated I would like them to be saved every time I change table 
cell.

Thans for any guidelines suggestions etc. 
Best regards


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

Reply via email to