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 ?

4

2 回答 2

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
  });
});
于 2013-02-07T20:36:34.697 回答
1

当用户点击时,您可以简单地更新每一行savesaverow(target)在演示的函数中,target是保存链接,因此您可以使用以下命令获取该行:

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*/
    })
};
于 2012-12-01T20:33:36.053 回答