数据表不仅仅更新此行而是更新所有表

时间:2016-10-07 21:13:13

标签: javascript php datatable

我拉PHP数据并包含在我的表格中,更具体,在标签tbody内部,一切正常,直到意识到当我通过fnUpdate更新表格的一行时,这不会只更新一行而是更新全部表数据表。问题是:我如何让它更新这一行?

代码:

<script type="text/javascript">

  $(document).ready(function(){

      var table = $('#tabela_produto2');
      var tabela = table.dataTable({    

        "pageLength": 1,
        "lengthMenu": [[7, 25, 50, 100, -1], [7, 25, 50, 100, "Todas"]],

         "aoColumnDefs": [
            { "bSortable": false, "aTargets": [-9] },
            { "width": "7%", "targets": 0 }
          ],
            "oLanguage": {

      "sLengthMenu":    "Produtos de Locação por Página: _MENU_",
      "sInfo":          "_TOTAL_ Produtos de Locação",
      "sInfoFiltered":  "(Total: _MAX_ Produtos de Locação)"
    },
    "sDom": '<"top"fi>rt<"bottom"lp><"clear">',
              "order": [
        [0, "asc"]
      ], // set first column as a default sort by asc,

      "bPaginate": true
           });

      table.on('click', '.atualiza', function (e) {
      e.preventDefault();

      var nRow = $(this).parents('tr')[0]; // here the row to update
      tabela.fnUpdate('test33' , nRow,4,false); // here do update (but it
                          update all table and not just this line                                                
      tabela.fnDraw();
    });
        //tabela.fnUpdate('test' , 0,0,false ); // Row
        //tabela.fnDeleteRow( 0 );['a', 'b', 'c', 'd', 'e','d','4','4','9']
       //tabela.fnDraw();

  });
</script>

0 个答案:

没有答案
相关问题