繁体   English   中英

Editor_dataTables-多个表的内联编辑

[英]Editor_dataTables - Inline Edit for multiple tables

我正在使用dataTables Editor,但内联编辑不适用于所有表。
仅第二个表允许内联编辑。 如何才能从同一页面上的所有表进行内联编辑? 两个表都填充有数据tho。 php是var编辑器; //在示例中使用全局变量来提交和返回数据

$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
    ajax: "../php/staff2.php",
     "bProcessing": true,
    "bServerSide": true,
    table: "#example1",
    fields: [ {
            label: "subject:",
            name: "subject"
        }, {
            label: "ApplicationDate:",
            name: "ApplicationDate"
        }, {
            label: "PreferedPaymentDate:",
            name: "PreferedPaymentDate"
        }, {
            label: "Ledger:",
            name: "Ledger"
        }, {
            label: "BranchName:",
            name: "BranchName"
        }, {
            label: "AppNumber:",
            name: "AppNumber",
        }
    ]
} );

// Activate an inline edit on click of a table cell
    $('#example1').on( 'click', 'tbody tb', function () {
editor.inline( this );
    } );

$('#example1').DataTable( {
    dom: "Tfrtip",
    "searching": false,
    "bInfo" : false,
    "bPaginate": false,
    "bSort": false,
    "bVisible": false,
    ajax: "../php/staff2.php",
    columns: [
        { data: null, defaultContent: '', orderable: false },
        { data: "subject" },
        { data: "ApplicationDate" },
        { data: "PreferedPaymentDate" },
        { data: "Ledger" },
        { data: "BranchName" },
        { data: "AppNumber", render: $.fn.dataTable.render.number( ',', '.', 0, '$' ) },

    ],
    order: [ 1, 'asc' ],
    tableTools: {
        sRowSelect: "os",
        sRowSelector: 'td:first-child',
        aButtons: [
            { sExtends: "editor_create", editor: editor },
            { sExtends: "editor_edit",   editor: editor },
            { sExtends: "editor_remove", editor: editor }
        ]
    }
} )
                     } );

      $(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
    ajax: "../php/staff2.php",
    table: "#example2",
    "bProcessing": true,
    "bServerSide": true,
    fields: [ {
            label: "subject:",
            name: "subject"
        }, {
            label: "ApplicationDate:",
            name: "ApplicationDate"
        }, {
            label: "PreferedPaymentDate:",
            name: "PreferedPaymentDate"
        }, {
            label: "Ledger:",
            name: "Ledger"
        }, {
            label: "BranchName:",
            name: "BranchName"
        }, {
            label: "AppNumber:",
            name: "AppNumber",
        }
    ]
          } );

// Activate an inline edit on click of a table cell
     $('#example2').on( 'click', 'tbody td', function () {
editor.inline( this );
     } );

$('#example2').DataTable( {
    dom: "Tfrtip",
    "searching": false,
    "bInfo" : false,
    "bPaginate": false,
    "bSort": false,
    "bVisible": false,
    ajax: "../php/staff2.php",
    columns: [
        { data: null, defaultContent: '', orderable: false },
        { data: "subject" },
        { data: "ApplicationDate" },
        { data: "PreferedPaymentDate" },
        { data: "Ledger" },
        { data: "BranchName" },
        { data: "AppNumber", render: $.fn.dataTable.render.number( ',', '.', 0, '$' ) },

    ],
    order: [ 1, 'asc' ],
    tableTools: {
        sRowSelect: "os",
        sRowSelector: 'td:first-child',
        aButtons: [
            { sExtends: "editor_create", editor: editor },
            { sExtends: "editor_edit",   editor: editor },
            { sExtends: "editor_remove", editor: editor }
        ]
    }
} );
              } );

<div class="container">
    <section>
        <table id="example1" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>
                    <th>First name</th>
                    <th>Last name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th width="18%">Start date</th>
                    <th>Salary</th>
                </tr>
            </thead>
        </table>

<div class="container">
    <section>   
        <table id="example2" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>

                    <th>First name</th>
                    <th>Last name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th width="18%">Start date</th>
                    <th>Salary</th>
                </tr>
            </thead>
        </table>

这样尝试

editor1 = new $.fn.dataTable.Editor( { ....for example1 table
editor2 = new $.fn.dataTable.Editor( { ....for example2 table

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM