Wierd things happening in child records.

Wierd things happening in child records.

asystemsausasystemsaus Posts: 15Questions: 5Answers: 0

Hi, I have a list of users which I display in a table, following the examples given all looks good.
However, if I click on the green plus sign the value in the second column appears in the search box of that table and only that record is shown.

  var table = $('#membertable').DataTable( {
        "scrollY" : "700",
           "ajax" : "includes/getusersinfo.php",
         "columns": [
             {
                 "className":      'details-control',
                 "orderable":      false,
                 "data":           null,
                 "defaultContent": ''
             },
             { "data": "email" },
             { "data": "title" },
             { "data": "fname" },
             { "data": "lname" },
             { "data": "adminlevel" },
             { "data": "coach" }
         ],
         "order": [[1, 'asc']],
    
     } );

     // Add event listener for opening and closing details
     $('#membertable 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
             d = row.data();
               row.child( format(d) ).show();
               tr.addClass('shown');
           }
       } );

Everything works fine until I add an <input id="pwd" name="pwd"> field into the format function.
If i leave it out, its fine, as soon as I add it and click on the + the email field value ends up in the [Search] field for the table and all the other records disappear.
And its always the same email address which has the lowest row id that it happens to.

So I guess the question is.... .Is it possible to use input fields in the format functions when trying to display child records.

Replies

  • kthorngrenkthorngren Posts: 20,313Questions: 26Answers: 4,771

    Is it possible to use input fields in the format functions when trying to display child records.

    There is nothing special about the child rows or how you use them in the format function. As long as its proper HTML you can format the child however you like.

    click on the + the email field value ends up in the [Search] field for the table and all the other records disappear.

    This problem is specific to your setup. We would need to see this in order to help. Please provide a link to your page or a test case replicating the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • asystemsausasystemsaus Posts: 15Questions: 5Answers: 0

    HI, I totally removed the format function, added again without the <input field and it worked. So i put just <input id="pwd" /> and the issue has disappeared.
    added the rest of the <input stuff and still working perfectly... No idea why.

This discussion has been closed.