使用Jquery的DataTable進(jìn)行數(shù)據(jù)表處理非常方便,常遇到的一個(gè)問題就是刪除一行后頁面必須進(jìn)行更新,需要注意的方法如下:前臺(tái)頁面中初始化table時(shí)注意:
復(fù)制代碼 代碼如下:
var table = $('#sorting-advanced');
table.dataTable({
'bServerSide': true,
'sAjaxSource': 'servlet/UserList<%=queryString%>',
'bProcessing': true, 'bStateSave': true,
'aoColumnDefs': [
{ 'bSortable': false, 'aTargets': [0,1,6]}
],
'sPaginationType': 'full_numbers',
'sDom': '<"dataTables_header"lfr>t<"dataTables_footer"ip>',
'fnInitComplete': function( oSettings )
{
// Style length select
table.closest('.dataTables_wrapper').find('.dataTables_length select').addClass('select blue-gradient glossy').styleSelect();
tableStyled = true;
}
});
復(fù)制代碼 代碼如下:
function deleteConfirm(deleteID)
{
$.modal.confirm('確實(shí)要?jiǎng)h除此用戶嗎?', function()
{
$.ajax('servlet/DeleteUser', {
dataType : 'json',
data: {
userID: deleteID
},
success: function(data)
{
if (data.success =='true')
{
$.modal.alert('刪除成功!');
start = $("#sorting-advanced").dataTable().fnSettings()._iDisplayStart;
total = $("#sorting-advanced").dataTable().fnSettings().fnRecordsDisplay();
window.location.reload();
if((total-start)==1){
if (start > 0) {
$("#sorting-advanced").dataTable().fnPageChange( 'previous', true );
}
}
}
else
{
$.modal.alert('刪除發(fā)生錯(cuò)誤,請(qǐng)聯(lián)系管理員!');
}
},
error: function()
{
$.modal.alert('服務(wù)器無響應(yīng),請(qǐng)聯(lián)系管理員!');
}
});
}, function()
{
//$.modal.alert('Meh.');
});
};
新聞熱點(diǎn)
疑難解答
圖片精選