具有Jeditable的数据表,如何在编辑模式下进行初始设置? (或始终处于编辑模式)

时间:2011-12-05 15:58:20

标签: plugins datatables

使用datatables插件时,是否可以在编辑模式下启动Jeditable字段?

Jeditable网站说解决方案(不使用数据通信):

您可以在文档加载时触发已使用的事件。例如:

$(function() {
$("#editable").trigger("click");

如何在数据表中访问它,这是我的代码:

    var oTable;
    $(function () {
        oTable = $('#calendarTable').dataTable({
            "bPaginate": false,
            "bSort": false,
            "bFilter": false,
            "bInfo": false,
            "aoColumns": [
                null,
                null,
                null,
                null,
                { "bVisible": false },
                { "bVisible": false },
                { "bVisible": false },
                { "bVisible": false },
                { "bVisible": false },
                { "bVisible": false },
                { "bVisible": false },
                { "bVisible": false },
                { "bVisible": false },
                { "bVisible": true }
            ]

        });

        //$("#editable").trigger("click");
        // oTable.fnGetNodes()).editable.trigger("click");

        oTable.editable("disable");

        var year;
        var lobid;
        var officeid;

        year = $('#hv_year').val();
        lobid = $('#hv_lob').val();
        officeid = $('#hv_office').val();

        var url;
        url = "save.asp";
        url = url + "?year=" + year;
        url = url + "&lobid=" + lobid;
        url = url + "&officeid=" + officeid;


        /* Apply the jEditable handlers to the table */
        $('td:eq(4)', oTable.fnGetNodes()).editable(url, {
            "callback": function (sValue, y) {
                var aPos = oTable.fnGetPosition(this);
                oTable.fnUpdate(sValue, aPos[0], aPos[1]);
            },
            "submitdata": function (value, settings) {
                return {
                    "row_id": this.parentNode.getAttribute('id'),
                    "column": oTable.fnGetPosition(this)[2]
                };
            },
            tooltip: 'Click to Edit',
            height: "40px",
            type: 'textarea',
            onblur: 'ignore',
            cancel: 'Cancel',
            submit: 'Save',
            indicator: '<img src="images/loader.gif">'

        });

1 个答案:

答案 0 :(得分:1)

我认为你可以链接点击:

   $('td:eq(4)', oTable.fnGetNodes()).editable(url, {
        "callback": function (sValue, y) {
            var aPos = oTable.fnGetPosition(this);
            oTable.fnUpdate(sValue, aPos[0], aPos[1]);
        },
        "submitdata": function (value, settings) {
            return {
                "row_id": this.parentNode.getAttribute('id'),
                "column": oTable.fnGetPosition(this)[2]
            };
        },
        tooltip: 'Click to Edit',
        height: "40px",
        type: 'textarea',
        onblur: 'ignore',
        cancel: 'Cancel',
        submit: 'Save',
        indicator: '<img src="images/loader.gif">'

    }).trigger("click");