Header of some columns?

(7 posts) (2 voices)

Tags:

No tags yet.

  1. spyhunter88, Member

    Hi,

    I have a group of column and I want to group them into a header column to easy see. Before:
    Week_Sales | Week_Cost | Week_Target | Month_Sales | Month_Cost | Month_Target

    To this:


    ________Week________|________Month_________
    Sales_|_Cost_|_Target_|_Sales_|_Cost_|_Target

    I already think to CrossTab but if I go this way, I have to separate my query into 2 queries and union them with a "Type" column. Another problem, I already take a crosstab before these columns (Like: Day_1 | Day_2 .... | Day_n | Week_Sales | ...)

    Thanks,

  2. myDBR Team, Key Master

    Hi,
    easiest way of doing that would be using couple of lines of JavaScript. Something along lines of this (add the row and set the CSS classes):

    --
    myDNR Team

  3. spyhunter88, Member

    Yes,

    I made a dbr.javascript like below. But I run into a problem when I take a new_popup to it self, it duplicate the effects of javascript and make double added column. First I already have 2 row header because I use crosstab before.

    /* Separate header line */ select 'dbr.javascript', concat('$(function() { $("th.cell_ct_top:last").remove(); // Remove blank header row before, its colspan is 10 and I want to separate into 2 header with Text $("tr.row_header").append("<th class=\'cell_ct_top\' colspan=\'5\'>Week W.', WEEK(toDate) ,'</th>"); $("tr.row_header").append("<th class=\'cell_ct_top\' colspan=\'5\'>Month M.', LPAD(MONTH(toDate),2,'0') ,'</th>"); // It adds 4 columns, 2 in the first header row, 2 in the second one. $("th.cell_ct_top:last").remove(); // I must remove the 2 added column in the second header row <=> the last header row. $("th.cell_ct_top:last").remove(); })');

    In another way, I choose new_window but my Customer will request to new_popup. Haha.

    Thanks,

  4. myDBR Team, Key Master

    Looks like you are using it against a crosstab report which will make things more complicated. Just use normal tables.

    select 'dbr.resultclass', 'mytable';
    
    select 'ABC', 10 as 'Sales', 20 as 'Cost', 30 as 'Target', 10 as 'Sales', 20 as 'Cost', 30 as 'Target';
    
    select 'dbr.javascript', "
    $('<tr><th class=""cell_ct_top""></th><th class=""cell_ct_top"" colspan=""3"">Week</th><th class=""cell_ct_top"" colspan=""3"">Month</th></tr>').insertBefore($('.mytable thead tr'));
    $('.mytable thead tr th.cell_header').removeClass('cell_header').addClass('cell_ct');
    ", 'onload';

    In another way, I choose new_window but my Customer will request to new_popup. Haha.

    Did not see what you are referring to with this one.

    --
    myDBR Team

  5. spyhunter88, Member

    Sorry I need some support,

    I put 2 type of table in 2 Tab, so if I can specify exactly table, it remove/add to last report in Tab. So I try below:
    select 'dbr.resultclass', 'org_table'; /* Separate header line */ select 'dbr.javascript', concat(' $(".org_table > th.cell_ct_top").last().remove(); $(".org_table > th.cell_ct_top").last().after("<th class=\'cell_ct_top\' colspan=\'6\'>W', WEEK(toDate) ,'</th>"); $(".org_table > th.cell_ct_top").last().after("<th class=\'cell_ct_top\' colspan=\'6\'>Y',YEAR(toDate),' .M', LPAD(MONTH(toDate),2,'0') ,'</th>"); '), 'onload';

    If I use $('th.cell_ct_top'), it works. So I think the script runs before the css is built, so the child can not be select or something like that. So is there something to work around this?

    Thanks,

  6. myDBR Team, Key Master

    In CSS ">" is a children selector. This means that when using ".org_table > th.cell_ct_top", the th should be a direct child of org_table (which it is not).

    What you can use is a descendant selector and use format ".org_table th.cell_ct_top".

    You can easily test out the CSS selector in browser's debugger mode just by using the CSS inside jQuery call, $(".org_table th.cell_ct_top"), and see what elements match your criteria.

    --
    myDBR Team

  7. spyhunter88, Member

    Nice, it works great. My bad javascript.

    Thanks.


Reply

You must log in to post.