我做了一行remove(),然后尝试fnDestroy()并初始化数据表。记录计数和分页不受影响(不刷新*数据表)*。
我也试过使用fnDraw(),但还是没有用。
我查看了页面源代码,删除的行html仍然存在。
我正在使用Ajax删除行。感谢你的帮助
这是我的删除脚本:

$(document).ready(function()
        {
            $('table#sample_1 td a.delete').click(function()
            {
                if (confirm("Are you sure you want to delete this row?"))
                {
                    var id = $(this).parent().parent().attr('id');
                    var data = 'id=' + id ;
                    var parent = $(this).parent().parent();

                    $.ajax(
                    {
                           type: "POST",
                           url: "process.php",
                           dataType: "json",
                           data: data,
                           cache: false,

                           success: function()
                           {

                            var dtable = $('#sample_1').dataTable();
                        dtable.fnDestroy();


                        parent.fadeOut('slow', function() {$(this).remove();});


                        //Reinitialize the datatable
                        $('#sample_1').dataTable({
                                    "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
                                    "sPaginationType": "bootstrap",
                                    "oLanguage": {
                                        "sLengthMenu": "_MENU_ records per page",
                                        "oPaginate": {
                                            "sPrevious": "Prev",
                                            "sNext": "Next"
                                        }
                                    },
                                    "aoColumnDefs": [{
                                        'bSortable': false,
                                        'aTargets': [0]
                                    }]
                        });

                           }
                     });
                }
            });


        });


        </script>

最佳答案

可以使用fnDeleteRow删除数据表中的行。此函数将自动重新绘制表。
参考此,http://datatables.net/api

08-18 06:16
查看更多