Bit of Javascript Help Please!

(7 posts) (2 voices)

Tags:

  1. ajdjackson, Member

    Hi

    I've created a crosstab and would like to add a blank row before and a blank row after certain rows based on their contents.

    I've managed to get this far - the example is looking for a row that contains Net Current Assets:


    select 'dbr.javascript'," var rind = $('tr td:contains(\"Net Current Assets\")').closest(\"tr\").index(\"tr\"); $('tbody > tr:nth-child('+rind+')').after('<tr></tr>'); ";

    I believe I'm getting the index of the row ok it's just the adding of the rows where nothing is happening.

    Any thought?

    Thanks

    Jake

  2. myDBR Team, Key Master

    In addition to the TR-element, you need to add the TD-elements (pfeferably with the correct COLSPAN) with some content so that the row will have height.

    If you really want to use JavaScript, you can use syntax:

    select 'dbr.javascript', "
    $('td:contains(\"Net Current Assets\")').parent().each( function() {
    $(this).before('<tr class=\"row\"><td colspan=\"'+$(this).children().length+'\" class=\"cell\"> </td></tr>');
    });
    ";

    Note that you can also build a result table from multiple parts if you use dbr.resultset.options's 'skip_footer' and 'skip_headers'.

    --
    myDBR Team

  3. ajdjackson, Member

    Thanks that worked great. I would never have appreciated the colspan requirement.

    I’ve split the crosstabs previously but this gives issues when exporting in that the hidden headers appear in the excel files.

    Is there a way in exporting to excel you can prevent any elements that have been hidden in css from appearing in export?

    Cheers

    Jake

  4. myDBR Team, Key Master

    There is really no CSS support in Excel. myDBR does interprete some direct CSS styles to Excel style (for example font / cell-styles), but display:none is not among them.

    What is the use case where you have to do the hiding in CSS?

    --
    myDBR Team

  5. ajdjackson, Member

    Hi

    An example of where I have to hide a row is when I'm creating a Balance Sheet.

    In this case I find I have to hide the last row which is the 'grand total' row.

    I use select 'dbr.css','tr.summary_row.sortbottomhdr_change,tr.summary_row.sortbottom {display:none;}';

    I find this row still displays even when I use select 'dbr.summary.options','limit_summary_level',1;. My understanding of this is that only level 1 summaries display but I find that the Level 0 one displays as well therefore I hide it.

    This row is exported to excel even although it's hidden.

    Cheers

    Jake

  6. myDBR Team, Key Master

    The command:

    select 'dbr.summary.options','limit_summary_level',1;

    means that do not show summary levels beyond 1 (i.e show 0 and 1).

    To show only summary level 1, use:

    select 'dbr.summary.options','limit_summary_level', '=1';

    --
    myDBR Team

  7. ajdjackson, Member

    Great - thanks for clearing that up.

    Cheers

    Jake


Reply

You must log in to post.