0

我有一个表(在 asp.net 中生成)显示有很棒的 DataTable jQuery 插件。我的表有一些可编辑的字段(我使用了jQuery Datatables editable),并且我的一些表中已经有一些自定义字段。

这是一个只有 3° 列可编辑的表格,它发送两个额外的参数(我的表格的第 3 列和第 1 列):“cell”和“trustedid”。这完美地工作:

$('#ctl00_MainContent_tradGrid').dataTable({
    bJQueryUI: true,
    "sPaginationType": "full_numbers",
    "bSortClasses": false
    }).makeEditable({
        sUpdateURL: "/updateData.aspx<% Response.Write(parameters); %>",
        fnOnEditing: function (input) {
            cell = input.parents("tr")
                    .children("td:nth-child(3)")
                    .text();
            trustedid = input.parents("tr")
                    .children("td:nth-child(1)")
                    .text();
            return true
        },
        oUpdateParameters: {
            cell: function () { return cell; },
            trustedid: function () { return trustedid; }
        },
        oEditableSettings: { event: 'click' }
    });

我在最后一个可编辑列上还有另一个带有复选框的表,并且工作正常,这是代码:

$('#ctl00_MainContent_tradGrid').dataTable({
    bJQueryUI: true,
    "sPaginationType": "full_numbers",
    "bSortClasses": false
}).makeEditable({
    sUpdateURL: "/updateChecked.aspx",
    aoColumns: [
        {}, {}, {}, {
            type: 'checkbox',
            submit: 'Ok',
            cancel: 'Cancel',
            checkbox: { trueValue: 'Yes', falseValue: 'No' }
        }
    ]
});

现在我需要在第二个示例中使用单个自定义参数,但不能这样做!这是我的尝试:

$('#ctl00_MainContent_tradGrid').dataTable({
    bJQueryUI: true,
    "sPaginationType": "full_numbers",
    "bSortClasses": false
}).makeEditable({
    sUpdateURL: "/updateChecked.aspx",
    fnOnEditing: function (input) {
        trustedid = input.parents("tr")
                .children("td:nth-child(1)")
                .text();
        return true
    },
    oUpdateParameters: {
        trustedid: function () { return trustedid; }
    },
    aoColumns: [
        {}, {}, {}, {
            type: 'checkbox',
            submit: 'Ok',
            cancel: 'Cancel',
            checkbox: { trueValue: 'Yes', falseValue: 'No' }
        }
    ]
});

但它得到错误:Uncaught ReferenceError: trustedid is not defined

我怎样才能做到这一点?

4

1 回答 1

0

fnOnEditing 仅在 text、select 和 textarea 上调用: if(settings.type == "text" || settings.type == "select" || settings.type == "textarea") 在 jquery.dataTables.editable.js 的第 209 行附近。我将它与一些自动完成字段一起使用并且它有效。您可以在该列表中添加复选框,但可能您还需要在其中进行一些其他更改,因为复选框上的 .val() 不会返回正确的值。

于 2013-10-03T10:48:09.590 回答