Search code examples
jqueryappendiccube

Append table via jQuery


I am trying to automatically add a table to a report after the end of the loading process. I tried that using the jQuery .append() Method on the report (context.$report):

function consumeEvent( context, event ) {                                
    if (event.name == 'ic3-report-after-build') {
        context.$report.append( "<table>...</table>" );
    }                                                                       
}

Unfortunately nothing happens. What am I doing wrong?


Solution

  • You have correct code, but still it should be enhanced a bit.

    Try this one:

    Report JavaScript

    function consumeEvent( context, event ) {                                
        if (event.name == 'ic3-report-after-build') {
            context.$report.find('table#custom').remove()
            context.$report.find('.ic3-report-content-container')
            .append('<table id="custom"><tr><td>Table</td></tr></table>')
        }                                                                       
    }
    

    Report CSS

    table#custom {
        border: 1px solid #black;
        position: absolute;
        top: 0;
    }