【问题标题】:Can you set certain cells to read only in an editable column for DataTables Editable?您可以将某些单元格设置为只读 DataTables Editable 的可编辑列吗?
【发布时间】:2013-08-10 17:03:28
【问题描述】:

我正在使用 jQuery 插件 DataTables 及其可编辑插件。我可以通过参数 aoColumns 将列设置为只读:

 "aoColumns": 
               [
                    null,   
                    {}, 
                    {
                        indicator: 'Saving...',
                        type: 'select',
                        submit: 'Update',
                        loadURL: 'Home/Test',
                    }
                ]

我还可以通过添加 read_only 类将每个单独的单元格设置为只读:

<td class="read_only">...</td>

只要我不指定 aoColumns(即默认情况下所有单元格都是可编辑的),上述内容就可以正常工作。是否可以在可编辑列中将某些单元格设为只读?请注意我使用 aoColumns 的原因是使用下拉框和 loadurl。

【问题讨论】:

  • 您的意思是要将列中的所有单元格设置为只读?
  • 不,只有列中的某些单元格。例如,您有一个状态列。状态可以是已提交、已批准、进行中和已完成。如果状态为 Completed,我希望单元格为只读;对于其他状态,用户可以更改为适用的状态。

标签: jquery datatables readonly cells


【解决方案1】:

我使用行回调来解决类似的问题。像这样的:

 "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
            /* Append the read_only class to Completed rows */
            if ( aData["status"] == "Completed" )
            {
                nRow.className = "read_only";
            }
        },

http://datatables.net/usage/callbacks

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-15
    • 1970-01-01
    • 1970-01-01
    • 2015-03-31
    相关资源
    最近更新 更多