0

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 ?

Prathamesh mhatre
  • 1,015
  • 5
  • 17
  • 32

2 Answers2

3
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
  });
});
1

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*/
    })
};
charlietfl
  • 170,828
  • 13
  • 121
  • 150
  • Thanks for your reply, But the problem is I want to do is batch update, I will make changes and then in the end want to save all row that I have edited. Can you help me in this – Prathamesh mhatre Dec 01 '12 at 20:37