2012-04-24 6 views
3

jquery Tablesorterプラグインを使用しています。行を削除してから列を並べ替えると、削除された行が再度表示されます。私がここでstackoverflowで読んだことは、私がtrigger.updateやtrigger.appendcacheを追加する必要があるかもしれないということですが、それはうまくいかないようです。間違った場所に置いているかもしれません。何か案は?Tablesorter並べ替え後に削除済み行を追加する

<script type="text/javascript"> 
$(function() { 
    $(".tablesorter").tablesorter({ 
     headers: { 0: { sorter: false }, 1: { sorter: false }, 2: { sorter: false }, 3: { sorter: false} }, 
     widgets: ['zebra'], 
     widgetZebra: { css: ['alt-even-class', 'alt-odd-class'] } 
    }); 

    $('div#deleteDialog').dialog({ 
     autoOpen: false, 
     width: 400, 
     height: 200, 
     modal: true, 
     position: 'center', 
     resizable: false, 
     buttons: { 
      OK: function() { 
       var delID = $('div#deleteDialog input').val(); 
       $.post('@Url.Action("Delete", "Plate")', { id: delID }, function (data) { 
        if (data === 'delete') { 
         $('tr#' + delID).remove(); 
         resetGrid(); 
        } 
       }); 
       $(this).dialog('close'); 
      }, 
      Cancel: function() { 
       $(this).dialog('close'); 
      } 
     } 
    }); 

    $('table.tablesorter thead input:checkbox').change(function() { 
     $('table.tablesorter tbody input:checkbox').attr('checked', $('table.tablesorter thead input:checkbox').attr('checked')); 
    }); 

    $('#create').click(function() { 
     document.location.href = '@Url.Action("ItemSelect", "Plate")'; 
    }); 

    $('.menucosting_view').click(function() { 
     document.location.href = '@Url.Action("Details", "Plate")' + '/' + $(this).parent().parent().attr('id'); 
    }); 

    $('.menucosting_edit').click(function() { 
     document.location.href = '@Url.Action("Edit", "Plate")' + '/' + $(this).parent().parent().attr('id'); 
    }); 

    $('.menucosting_delete').click(function() { 
     $('div#deleteDialog input').val($(this).parent().parent().attr('id')); 
     $('div#deleteDialog').dialog('open'); 
    }); 
}); 

function resetGrid() { 
    $('.tablesorter tr').removeClass('alt-even-class').removeClass('alt-odd-class'); 
    $('.tablesorter tr:even').addClass('alt-even-class'); 
    $('.tablesorter tr:odd').addClass('alt-odd-class'); 
} 

+0

$( '。tablesorter')の場所を見つけました。trigger( 'update');下のresetGrid(); – Tmac

+0

あなた自身の質問に答えてください。 – webbiedave

答えて

6

resetGrid();下に置き$('.tablesorter').trigger('update');

+0

ありがとうTmac .. 2時間後。あなたの答えは私のために働いた...私の日を救った。ありがとうトン。いいぞ ! –

+0

素晴らしい、ありがとう! – Icarus

関連する問題