Please give me guide for generation Datatable with empty table

Please give me guide for generation Datatable with empty table

jschoijschoi Posts: 13Questions: 5Answers: 0
edited August 2023 in Free community support

How can I generate DataTable as below,

<script>
let table = $("#targetTable").DataTable({
        dom : "Bfrtip",
        ajax : {
            .......
        },
        columns : [
            {data:"COLUMN1"},
            {data:"COLUMN2"},
            {data:"COLUMN3"},
            {data:"COLUMN4"}
        ],
        columnDefs: [
            { targets: [0], visible: false }
        ],
        autoWidth: true,
        select : true,
        buttons : [
            {text: "New Report",
                action:(e, dt, node, config) => {
                    doAction("add_report")
                }
            }
        ],
        searching: false
    })
</script>
<body>
<table id="targetTable"></table>
</body>

As I know, it should be included <thead> information and matched with columns information.
but I don't need to match and sometimes can be un-matched in situation.

Please give guide for that.

Always thanks to DataTables.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    You don't need to provide a thead. DataTables will create one for you if you don't have one. Use columns.title to set the text for the header cells.

    Allan

  • jschoijschoi Posts: 13Questions: 5Answers: 0

    Thank you allan
    I appreciate for your advise always

Sign In or Register to comment.