亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JQuery DataTable刪除行后的頁(yè)面更新利用Ajax解決

 更新時(shí)間:2013年05月17日 17:07:07   作者:  
使用Jquery的DataTable進(jìn)行數(shù)據(jù)表處理非常方便,常遇到的一個(gè)問(wèn)題就是刪除一行后頁(yè)面必須進(jìn)行更新,下面與大家分享下使用Ajax的解決方法
使用Jquery的DataTable進(jìn)行數(shù)據(jù)表處理非常方便,常遇到的一個(gè)問(wèn)題就是刪除一行后頁(yè)面必須進(jìn)行更新,需要注意的方法如下:前臺(tái)頁(yè)面中初始化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;
}
});

'bStateSave': true, 這個(gè)必須設(shè)置,這樣就可以在刪除返回時(shí),保留在同一頁(yè)上'bStateSave': true, 這個(gè)必須設(shè)置,這樣就可以在刪除返回時(shí),保留在同一頁(yè)上
刪除的代碼如下
復(fù)制代碼 代碼如下:

function deleteConfirm(deleteID)
{
$.modal.confirm('確實(shí)要?jiǎng)h除此用戶(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ù)器無(wú)響應(yīng),請(qǐng)聯(lián)系管理員!');
}
});

}, function()
{
//$.modal.alert('Meh.');
});
};

其中只要是需要判斷一下當(dāng)前頁(yè)中是否有數(shù)據(jù),如果是最后一條的話(huà),就在刪除后調(diào)用
$("#sorting-advanced").dataTable().fnPageChange( 'previous', true );已回到上一頁(yè)中
注意$("#sorting-advanced").dataTable().fnPageChange( 'previous'); 是不行的,必需進(jìn)行刷新,否則頁(yè)面中顯示的iDisplayStart會(huì)從cookie中取得,還是刪除前的iDisplayStart

相關(guān)文章

最新評(píng)論