Show extra information, version datatable 1.10.10

Show extra information, version datatable 1.10.10

ArmandArthurArmandArthur Posts: 10Questions: 2Answers: 0

Hello,

I have this link: https://datatables.net/examples/api/row_details.html and i would like my code works with the version 1.10.10.

But the function "row" doesn't work with 1.10.10

Could you help me to find a solution please?

This question has an accepted answers - jump to answer

Answers

  • gyrocodegyrocode Posts: 126Questions: 6Answers: 30

    What DataTables version are you using?

    API method row() is available since version 1.10.0 and should be available in 1.10.10 as well.


    See more articles about jQuery DataTables on gyrocode.com.

  • ArmandArthurArmandArthur Posts: 10Questions: 2Answers: 0

    My version is 1.10.10.

    var table = $('#example').DataTable( {
    "ajax": "../ajax/data/objects.txt",
    "columns": [
    {
    "className": 'details-control',
    "orderable": false,
    "data": null,
    "defaultContent": ''
    },
    { "data": "name" },
    { "data": "position" },
    { "data": "office" },
    { "data": "salary" }
    ],
    "order": [[1, 'asc']]
    } );

    Which is the equivalent with aoColumnDefs instead of columns?
    Because when i use columms i have this message :
    Cannot read property 'mData' of undefined

  • kthorngrenkthorngren Posts: 21,309Questions: 26Answers: 4,947

    This page has the parameter naming conversion chart:
    https://datatables.net/upgrade/1.10-convert

    Cannot read property 'mData' of undefined

    Do you have 5 columns defined in your table in HTML?

    Kevin

  • ArmandArthurArmandArthur Posts: 10Questions: 2Answers: 0

    I have more, 6 columns.

  • kthorngrenkthorngren Posts: 21,309Questions: 26Answers: 4,947

    I have more, 6 columns.

    You defined only 5 columns. With columns you need to define something for each existing column. That is why you are seeing the Cannot read property error.

    Kevin

  • ArmandArthurArmandArthur Posts: 10Questions: 2Answers: 0

    Yes thanks your for the config but i have the message "row" is not a function.
    I need to convert the functions of the link which i had pasted here?

  • gyrocodegyrocode Posts: 126Questions: 6Answers: 30

    Please show your code where you use row() method.


    See more articles about jQuery DataTables on gyrocode.com.

  • ArmandArthurArmandArthur Posts: 10Questions: 2Answers: 0
    edited August 2017

    This is the code of the exemple

    $('#example tbody').on('click', 'td.details-control', function () {
    var tr = $(this).closest('tr');
    var row = table.row( tr );

        if ( row.child.isShown() ) {
            // This row is already open - close it
            row.child.hide();
            tr.removeClass('shown');
        }
        else {
            // Open this row
            row.child( format(row.data()) ).show();
            tr.addClass('shown');
        }
    } );
    

    And this is the code modified by me

            $('.table-taches-afaire tbody').on('click', 'td.details-control', function () {
                var tr = $(this).closest('tr');
                var row = tableTachesAfaire.fnGetNodes( tr );
    
                if ( tableTachesAfaire.fnIsOpen() ) {
                    // This row is already open - close it
                    row.child.hide();
                    tr.removeClass('shown');
                }
                else {
                    // Open this row
                    var content =  tableTachesAfaire.fnGetData(row);
                    tableTachesAfaire.fnUpdate( content+format(row));
                    tr.addClass('shown');
                }
        } );
    
  • gyrocodegyrocode Posts: 126Questions: 6Answers: 30
    Answer ✓

    This line:

    var row = tableTachesAfaire.fnGetNodes( tr );
    

    is not the same as:

    var row = table.row( tr );
    

    Consider using the code below instead:

    var row = tableTachesAfaire.api().row( tr );
    

    See more articles about jQuery DataTables on gyrocode.com.

  • ArmandArthurArmandArthur Posts: 10Questions: 2Answers: 0

    I changed datatable by Datatable and it's works!

This discussion has been closed.