Editor - Buttons showing default - Export and not Editor Buttons

Editor - Buttons showing default - Export and not Editor Buttons

creatorDotJScreatorDotJS Posts: 20Questions: 6Answers: 0

Debugger: http://debug.datatables.net/iyadex

Buttons showing are default and not Editor Buttons. Any help would be great!

            $.extend( $.fn.dataTable.defaults, {
                "dom": "Tfrtip",
                "responsive": true,
                "destroy": true,
                "processing": false,
                "serverSide": false,
                "columns": [
                    { "data": "isChecked" },
                    { "data": "newInvoiceNum" },
                    { "data": "qfInvoiceNum" },
                    { "data": "qfLineStr" },
                    { "data": "unitName" },
                    { "data": "orderPO" },
                    { "data": "installDate" },
                    { "data": "schedDate" },
                    { "data": "typeName" },
                    { "data": "areaName" },
                    { "data": "invoiceTotal" }
                ],
                "tableTools": {
                    sRowSelect: "os",
                    aButtons: [
                        { sExtends: "editor_create", editor: editor },
                        { sExtends: "editor_edit",   editor: editor },
                        { sExtends: "editor_remove", editor: editor }
                    ]
                }
        } );

This question has an accepted answers - jump to answer

Answers

  • creatorDotJScreatorDotJS Posts: 20Questions: 6Answers: 0

    I suspect the error might be occurring with the initialization of the editor.

     editor = new $.fn.dataTable.Editor( {
            ajax: "BackEnd/WebService.php",
            table: "#history",
            fields: [ {
                    label: "Done:",
                    name: "isChecked"
                }, {
                    label: "Invoice:",
                    name: "newInvoiceNum"
                }, {
                    label: "QInvoice:",
                    name: "qfInvoiceNum",
                }, {
                    label: "Line #:",
                    name: "qfLineStr",
                }, {
                    label: "Unit:",
                    name: "unitName",
                }, {
                    label: "PO:",
                    name: "OrderPO",
                }, {
                    label: "Install:",
                    name: "installDate",
                    def: isoDateString,
                    type: "date"
                }, {
                    label: "Schedule:",
                    name: "schedDate",
                    def: isoDateString,
                    type: "date"
                }, {
                    label: "Type:",
                    name: "typeName",
                }, {
                    label: "Area:",
                    name: "areaName",
                }, {
                    label: "Total:",
                    name: "invoiceTotal"
                }
            ]
        } );
    
  • allanallan Posts: 63,488Questions: 1Answers: 10,467 Site admin
    Answer ✓

    I have a feeling that this is due to the defaults being used for the DataTables configuration, rather than direct initialisation with the configuration object. Are you able to update your initialisation to include, specifically the tableTools object, in the initialisation please? I would probably consider that best practice anyway (although this does look like it might be a bug / limitation in TableTools) since the editor instance is being used and set in the defaults, which could cause issues with any other tables that are also initialised.

    The other thing to try would be to use a deep extend - i.e. $.extend( true, ... ) since the default is a shallow copy which might also be causing issues.

    Thanks,
    Allan

  • creatorDotJScreatorDotJS Posts: 20Questions: 6Answers: 0

    Thank you Allan. Yes, it worked when I did a direct initialisation for the tableTools object with the configuration object. Thank you!

This discussion has been closed.