Multiple Tables initialisation complex example

Multiple Tables initialisation complex example

MausinoMausino Posts: 61Questions: 19Answers: 0
edited December 2022 in DataTables 1.10

Link to test case:
https://datatables.net/examples/basic_init/multiple_tables.html

Hi, i know that is stupid question... but i didn't find the way how indipendent show 2 tables on one page if i have for each own column and requests...

I see that i initialize table by class but how i add separately the options for each table separately ?

    $('table.display').DataTable();

    $('#dataTableZakazky').DataTable( {
        order:  [[0, 'asc']],
        pageLength: 10,
        fixedHeader: {
            header: true,
            footer: true
        },
        data: tableDataZakazky,
        columns: [
            { data: 'poradie', title: 'Id'},
            { data: 'firma', title: 'Firma'},
            { data: 'oblast', title: 'Lokalita'},
            { data: 'od', title: 'Od'},
            { data: 'do', title: 'Do'},
            { data: 'os', title: 'Os'},
        ]
    } );

    $('#dataTableByty').DataTable( {
        order: [[3, 'asc']],
        pageLength: 50,
        fixedHeader: {
            header: true,
            footer: true
        },
        data: tableDataByty,
        columns: [
            { data: 'poradie', title: 'Id'},
            { data: 'ubytovatel', title: 'Ubytovateľ'},
            { data: 'oblast', title: 'Oblasť'},
            { data: 'od', title: 'Od'},
            { data: 'do', title: 'Do'},
            { data: 'os', title: 'Kapacita'},
            { data: 'typ', title: 'Typ'},
            { data: 'predajna_cena', title: 'Byt / Cena / Mesiac'},
        ]
    } );

<table id="dataTableZakazky" class="display" width="100%"></table>
<table id="dataTableByty" class="display" width="100%"></table>

Thank you so much :)

Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765
    Answer ✓

    Remove line 1 from your code snippet. Since you have different configurations you will initialize them separately like you have in the remaining code snippet. I'm guessing you are getting the Cannot reinitialise DataTable. error. Removing line 1 will eliminate the error.

    Kevin

  • MausinoMausino Posts: 61Questions: 19Answers: 0
    edited December 2022

    Hi @kthorngren i tried.. but i still have this issue in console

    Uncaught TypeError: aoColumns[srcCol] is undefined...

    Update: sorry i see that i have problem in other part of my code which change which coloumn will sort the table.. now i solved the issue..

    Thank you and sorry, i feel stupid.. but spend 3 hours and i lost hope that i wrote here

Sign In or Register to comment.