【问题标题】:Tablesorter editable, howto enable edit for a newly added rowTablesorter 可编辑,如何为新添加的行启用编辑
【发布时间】:2015-06-23 19:30:23
【问题描述】:

我使用带有可编辑和过滤插件的tablesorter。 此外,我使用寻呼机(不认为它相关)。

现在我的页面上有一个按钮,可以打开一个表单来向表中添加新行。但是我首先使用 ajax 调用更新数据库,如下所示:

function ajaxUpdateDb(action, record) {

var postdata = JSON.stringify(
{
    "Table": $(".tablesorter").attr("id"),
    "Action": action,
    "Record": record
});

try {
    $.ajax({
        type: "POST",
        url: "../ajax/UpdateData.ashx",
        cache: false,
        data: postdata,
        dataType: "json",
        success: getSuccess,
        error: getFail,
        async: true
    });
} catch (e) {
    displayMessage(e.message, "alert alert-danger");
}

function getSuccess(data) {
    $(".tablesorter").trigger('cancel');

    if (data && data.Success) {
        record.ID = data.Id;
        displayMessage(data.Message, "label label-success");
        updateTable(action, record);
    } else if (data) {
        displayMessage(data.Message, "alert alert-danger");
    } else {
        displayMessage("operation failed, unknwon error", "alert alert-danger");
    }
};

function getFail(jqXhr) {
    document.write(jqXhr.responseText);
};
}

然后,在返回 ajax 调用时,我实际上将行添加到 html 表中,如下所示:

$('.tablesorter tbody').append(toHtml(record));
$('.tablesorter').trigger('update', true);

toHtml(record) 函数为具有唯一 id 的行创建 html 代码(检查)。

该行已正确添加到表中,过滤和排序有效,但是...该行不可编辑,其他行仍可编辑。

如何使我新添加的行可编辑?

【问题讨论】:

标签: jquery ajax tablesorter


【解决方案1】:

我的解决方案是将可编辑列定义为数组而不是文本: editable_columns: [0, 1, 2, 3, 4]

【讨论】:

  • 谢谢,我会检查一下这是否是一个错误并将其压扁!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-05
  • 2013-11-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多