Reputation: 1085
I am using jquery EasyUi data grid. As per documentation at http://www.jeasyui.com/tutorial/datagrid/datagrid12.php
I have build up the datagrid. Now what I want is there is a function acceptchanges in datagrid I want to save all the table changes in one go. And I need it urgent wanted to deploy project by tomorrow. Any suggestion ?
Upvotes: 0
Views: 8901
Reputation: 51
var rows = $('#dg').datagrid('getRows');
$.each(rows, function(i, row) {
$('#dg').datagrid('endEdit', i);
var url = row.isNewRecord ? 'test.php?savetest=true' : 'test.php?updatetest=true';
$.ajax(url, {
type:'POST',
dataType: 'json',
data:row
});
});
Upvotes: 3
Reputation: 171669
You could simply update each row when user hits save
. Within the function saverow(target)
in demo, target
is the save link so you can get the row using:
function saverow(target){
var $row=$(target).closest('tr');
/* map text of each cell to an array*/
var cellData= $row.find('td').map(function(){
return $(this).text();
}).get();
/* send array to server*/
$.post('upDateUrl', { rowData : cellData}, function(response){
/* do something with response*/
})
};
Upvotes: 1