jQuery DataTable - 将数据库中的数据放入输入元素

时间:2015-06-12 09:38:14

标签: jquery datatables jquery-datatables

我有一个jQuery DataTable,我想在输入元素中显示一些数据而不是在不可编辑的行中。

这是jQuery DataTable初始化代码:

var table = $('#monthly_table').DataTable({
        processing: true,
        serverSide: true,
        dom: "fr<'clear'>Ttip",
        ajax: '{{ url("reports/row-details-data") }}',
        tableTools: {
            sRowSelect: "os",
            sSwfPath: "../Content/DataTables/swf/copy_csv_xls_pdf.swf",
            aButtons: [
                {
                    sExtends: "xls",
                    sButtonText: "Export to Excel",
                    sButtonClass: "save-collection btn-default"

                },
                {
                    sExtends: 'print',
                    sButtonText: "Print",
                    sButtonClass: "btn-default"
                }
            ]
        },
        columns: [
            {data: 'id', name: 'report_id'},
            {data: 'name', name: 'report_name'},
            {data: 'value', name: 'report_value'}
        ]
   });

此时数据以html普通表形式出现。我希望这些值显示在表格内的输入中。就像下图所示:

DataTables example- Live DOM ordering

感谢所有帮助。

1 个答案:

答案 0 :(得分:0)

您可以使用我在jQuery Datatables文档中找到的此方法: https://datatables.net/reference/api/cell().data()

实施例: var cell = table.cell(4,1​​); cell.data( “值”)绘制();

不要忘记使用.draw()刷新表格。

更新: 或者使用table.cell(4,1​​).data(value).draw()

相关问题