can't get data from row without using editor

can't get data from row without using editor

LapointeLapointe Posts: 430Questions: 81Answers: 4

Hello
Row are displayed correctly.
I just want get row data content on click but I can't.

...
    $(document).ready(function() {
        var table = $('#donnees').DataTable( {                      
            ajax: "getdata.php?T=menu",
            dom: "t",
            pageLength: -1,
            ordering: false,
            columns: [ {data: 'Libelle'} ]
        });

        $('#donnees').on( 'click','tbody', function () {
                var d = table.rows($(this)).data();
        } );
    });
....
<body class="dataTables">
    <div class="container">
        <table id="donnees" class="display" style="width:50%">
            <thead>
                <tr style="text-align:left">
                    <th></th><th></th>
                </tr>
            </thead>
        </table>
    </div>
</body>
</html>

Does somebody have an idea please ?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,247Questions: 26Answers: 4,760
    Answer ✓

    You need to adjust your selector a bit to something like this:
    $('#donnees').on( 'click','tbody tr', function () {

    Notice the tr in the selector. Basically $(this) was the tbody but you want it to be the row.

    Kevin

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    Thanks a lot... I did try many way but never find that.
    :)

This discussion has been closed.