Uncaught TypeError: Cannot read property 'DT_RowId' of undefined

Uncaught TypeError: Cannot read property 'DT_RowId' of undefined

iraldoadiraldoad Posts: 4Questions: 2Answers: 0

When I add parameters to the datatable it throws this error.

Uncaught TypeError: Cannot read property 'DT_RowId' of undefined
at j (c967878_jquery.dataTables.min_2.js:1)
at R (c967878_jquery.dataTables.min_2.js:1)
at D (c967878_jquery.dataTables.min_2.js:1)
at HTMLTableElement.<anonymous> (c967878_jquery.dataTables.min_2.js:2)
at Function.each (ed3bc16_jquery_2.js:1)
at Z.fn.init.each (ed3bc16_jquery_2.js:1)
at Z.fn.init.qe [as dataTable] (c967878_jquery.dataTables.min_2.js:2)
at loadTable (b025d13_components_1.js:4)
at init (b025d13_components_1.js:27)
at (index):848

This is the configuration:

    $('#trace_table').dataTable({
        "paging": true,
        "ordering": true,
        "info": true,
        "language": {
            "url": "/bundles/app/vendor/datatables/media/js/locale_es.json"
        },
        "order": [[0, "desc"]],
        "columnDefs": [
            {"orderable": false, "targets": 5}
        ],
        "serverSide": true,
        "ajax": Routing.generate('audit_api_list'),
        "data": function (d) {
            d.filter_from = $('#filter_from').val();
            d.filter_to = $('#filter_to').val();
            d.filter_user = $('#filter_user').val();
            d.filter_type = $('#filter_type').val();
        }
    });

This question has an accepted answers - jump to answer

Answers

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

    I think this is the problem:

        "data": function (d) {
            d.filter_from = $('#filter_from').val();
            d.filter_to = $('#filter_to').val();
            d.filter_user = $('#filter_user').val();
            d.filter_type = $('#filter_type').val();
        }
    

    Are you trying to pass parameters in the ajax request?

    If yes then you need to create an object structure for the ajax option as shown in the ajax.data docs. Something like this:

        "ajax": 
            {
            "url": Routing.generate('audit_api_list'),
            "data": function (d) {
                d.filter_from = $('#filter_from').val();
                d.filter_to = $('#filter_to').val();
                d.filter_user = $('#filter_user').val();
                d.filter_type = $('#filter_type').val();
            }
        },
    

    Kevin

  • iraldoadiraldoad Posts: 4Questions: 2Answers: 0

    Yes, you are right. It's already working. Thank you!

This discussion has been closed.