如何在Datatables Jquery中创建一个只读列?

时间:2015-03-12 12:09:43

标签: jquery jquery-datatables

我正在使用jQuery Jeditable插件为Datatables编辑表格中的单元格。但是,我想只读一个列。我怎么能这样做?

我现在正在使用以下功能,这有助于我编辑列,但我想将第一列作为只读。请你帮助我吗?

$(document).ready(function() {

    /* Apply the jEditable handlers to the table */
    $('#example tbody td').editable(function(sValue) {
        /* Get the position of the current data from the node */
        var aPos = oTable.fnGetPosition(this);

        /* Get the data array for this row */
        var aData = oTable.fnGetData(aPos[0]);

        /* Update the data array and return the value */
        aData[aPos[1]] = sValue;
        return sValue;
    }, { "onblur": 'submit' }); /* Submit the form when bluring a field */
    oTable = $('#example').dataTable();

});

下面是我正在使用的表格。                                            公司名                 地址                 镇                                                                     微软海德拉巴                     拉巴威斯汀                     路政署                                                       CTS chennai                     辉煌                     奈                                                       CSC诺伊达                     DLF                     诺伊达                                                       INFy班加罗尔                     DLF大楼                     班加罗尔                            

1 个答案:

答案 0 :(得分:0)

您可以尝试这样做:使用class="readonly"标记表格中不可编辑的字段,并将其添加到选择器$('#example tbody td:not(.readonly)')