row.child(format(row.data()) ).show(); - show() not working

row.child(format(row.data()) ).show(); - show() not working

jtliviojtlivio Posts: 11Questions: 4Answers: 0
edited October 2021 in General

row.child(format(row.data()) ).show(); - show() not working

$('#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');
        }
    } );

Error

Property 'show' does not exist on type 'Api<any> | RowChildMethods<any>'.
Property 'show' does not exist on type 'Api<any>'

Don´t know more what to do, kindly give some feedback if you know why

Thanks

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    It appears to be working as expected here. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • jtliviojtlivio Posts: 11Questions: 4Answers: 0

    Thanks for helping, but is it possible to push the format() function with another solution?

    row.child( format(row.data()) ).show();

    Thanks

  • jtliviojtlivio Posts: 11Questions: 4Answers: 0

    Sample Capture

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    Thanks for helping, but is it possible to push the format() function with another solution?

    Not sure what you mean. format() is just a function. You can customize the function. Or you can name the function something else if you like. The function is used to format the HTML output.

    The code snippets look the same as the example Colin linked to. Do you have a format() function? Is the variable table assigned to the Datatable API?

    Can you post a test case showing the issue so we can help debug?

    Kevin

  • jtliviojtlivio Posts: 11Questions: 4Answers: 0
    edited October 2021

    Is i have a format function, the real problem is

    row.child(format(row.data())).show();This wont work, see image

    row.child.show() This works but not passing the format function

    function format ( d ) {
          // `d` is the original data object for the row
          return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
              '<tr>'+
                  '<td>Full name:</td>'+
                  '<td>'+d.Workshop.eTestUniqueNumber+'</td>'+
              '</tr>'+
              '<tr>'+
                  '<td>Extension number:</td>'+
                  '<td>'+d.CalculatedCertificateNumber+'</td>'+
              '</tr>'+
              '<tr>'+
                  '<td>Extra info:</td>'+
                  '<td>And any further details here (images etc)...</td>'+
              '</tr>'+
          '</table>';
        }
    
  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Is the variable table assigned to the Datatable API?

  • jtliviojtlivio Posts: 11Questions: 4Answers: 0

    Ok I found a solution was removing show() I don't know if it is a but with Typescript 3.9

    $('#example').on('click', 'td.dtr-control', function () {
          var tr = $(this).closest('tr');
          var row = table.row( tr );
    
          if ( !row.child.isShown() ) {
            alert("This row is already open - close it")
              // This row is already open - close it
              row.child.hide();
              tr.removeClass('shown');
          }
          else {
              // Open this row
              alert("Open this row")
              row.child(format(row.data()));
              tr.addClass('shown');
          }
      } );
    
Sign In or Register to comment.