Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82534

How to refresh table after adding or removing a row from server

$
0
0
Hi all,
What am I do wrong?
I add or delete a row with javascript, then I want to refresh the table.

I tried to several methods, but I could not make it.
What am I missing?

refreshDT($("#myTable"));

function refreshDT(d) {
	var dataTable = d.dataTable();
	dataTable.fnDraw();
}
OR I imported fnReloadAjax js
function refreshDT(d) {
	var dataTable = d.dataTable();
	var oSettings = dataTable.fnSettings();
	d.dataTableExt.oApi.fnReloadAjax(oSettings);
}
OR
function refreshDT(d) {
	var dataTable = d.dataTable();
	dataTable.fnClearTable(this);
	var i=0;
	$.getJSON('@Url.Action("GetAssetJSON", "Asset")', { get_param: 'value' }, function (data) {
	$.each(data, function (index, json) {
	dataTable.oApi._fnAddData(oSettings, json[i++]);
	});
	});
	oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
	dataTable.fnDraw();
}

Here is my table definition:
var oTable = $('#myTable').dataTable({
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "bAutoWidth": true,
                "bProcessing": true,
                "iDisplayLength": 20,
                "sAjaxSource": '@Url.Action("GetAssetJSON", "Asset")',
                "aaSorting": [[0, "desc"]],
                "aoColumns": [
                            { "sClass": "right", "sType": "numeric" },
                            null,
                            null,
                            null,
                            null,
                            null,
                            { "sType": "datetime_tr" },
                            null,
                           { "bSortable": false },
                           { "bSortable": false }
                        ],
                "sDom": 'Tfrtlip<"clear">'
            });

Viewing all articles
Browse latest Browse all 82534

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>