Tablesorter在排序后重新添加已删除的行 [英] Tablesorter Adding Deleted Row Back In After Sorting

查看:43
本文介绍了Tablesorter在排序后重新添加已删除的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jquery Tablesorter 插件,当我删除一行然后对该列进行排序时,已删除的行再次出现.从我在stackoverflow上读到的内容是,我可能需要添加trigger.update和/或trigger.appendcache,但这似乎不起作用,我可能把它放在错误的地方.有什么想法吗?

I'm using the jquery Tablesorter plugin and when I delete a row and then go to sort the column, the deleted row appears again. From what I've read here on stackoverflow is that I may need to add the trigger.update and/or the trigger.appendcache, but that didn't seem to work, thoug i may be placing it in the wrong place. Any ideas?

<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');
}

推荐答案

$('.tablesorter').trigger('update'); 放在 resetGrid(); 下代码>!

Place $('.tablesorter').trigger('update'); under resetGrid();!

这篇关于Tablesorter在排序后重新添加已删除的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆