Saturday, January 30, 2010

OBIEE Horizontal Pivot Sections Part 2

Based on this post: http://obiee101.blogspot.com/2010/01/obiee-horizontal-pivot-sections.html I was asked if this was possible:

image

Or a “carriage return” every x columns. So extra lines to Joe’s code fixed it:

    <script type="text/javascript">
    /* based orignal code by Joe Betram
    /* see:http://forums.oracle.com/forums/thread.jspa?threadID=1009297&tstart=0
    /* This Version John Minkjan :http://www.obiee101.blogspot.com/
    /* Thanks to Nandoo for noticing the IE bug
    */
    /* Set the number of columns */
    var intColumnNumbers = 5;

    function insertAfter( referenceNode, newNode )
    {
        referenceNode.parentNode.insertBefore(newNode, referenceNode.previousSibling);
    }
    var debug =1;
    var sectioncnt =0;
    var x =0;

    if (debug === 1) { document.write("Get all tables"+"<BR>");}
    var tables = document.getElementsByTagName('table');

    if (debug === 1) { document.write("Loop over the tables"+"<BR>");}
    for(var table=0; table < tables.length; table++){

    if(tables[table].className != 'PTSectsTable' ){
    continue;
    }

    if (debug === 1) { document.write("Found a pivot table"+"<BR>");}

    var tbody = tables[table].getElementsByTagName('tbody')[0];
    if (debug === 1) { document.write("Grabbed the tbody code"+"<BR>");}

    var trs = tbody.getElementsByTagName('tr');

    var new_tr = document.createElement('tr');
    var nw_tr =new Array();
    nw_tr[x] = document.createElement('tr');
    if (debug === 1) { document.write("Created the new_tr variable"+"<BR>");}

    while( trs.length > 0){

    var new_td = document.createElement('td');
    if (debug === 1) { document.write("Created a new TD element."+"<BR>");}

    var new_table = document.createElement('table');
    if (debug === 1) { document.write("Created a new table element."+"<BR>");}

    var new_tbody = document.createElement('tbody');
    if (debug === 1) { document.write("Created a new tbody element."+"<BR>");}

    new_tbody.appendChild(trs[0]);
    if (debug === 1) { document.write("Appended Section."+"<BR>");}

    new_tbody.appendChild(trs[0]);
    if (debug === 1) { document.write("Appended Data."+"<BR>");}

    new_table.appendChild(new_tbody);
    if (debug === 1) { document.write("Appended tbody to the table tag."+"<BR>");}

    new_td.appendChild(new_table);
    if (debug === 1) { document.write("Appended table to the TD tag."+"<BR>");}

    new_tr.appendChild(new_td);
    if (debug === 1) { document.write("Appended td to the overall TR tag."+"<BR>");}
    /*nw_tr[0].appendChild(new_td);*/
    sectioncnt = sectioncnt +1;
    if (debug === 1) { document.write(sectioncnt%intColumnNumbers+"<BR>");}

    if (sectioncnt%intColumnNumbers ===0){        
        nw_tr[x]=new_tr;
        var new_tr = document.createElement('tr');
        x =x+1;
    };
    }
    var y=0;
    for (y=0; y<nw_tr.length; y++)
    {
        tbody.appendChild(nw_tr[y]);
    }
    tbody.appendChild(new_tr);
    if (debug === 1) { document.write("Inserted the new_tr variable as the first child of tbody"+"<BR>");}
    }

    if (debug === 1) { document.write("Finished transposePivotTable"+"<BR>");}

    </script>

Till Next Time

15 comments:

Unknown said...

Hi John,

I have used your code for showing the horizontal pivot section, but the sections are not straight. There is a gap at the starting position of the sections.

Regards,
Vismay

Chris said...

This seems to work with the Chart Only Option. Do you know how I can use this if the chart is above a table?

John Minkjan said...

@vismay,

Can you eloborate a bit? Which space do you mean? You can use a program like firebug to identify it.

John Minkjan said...

@Chris,

Can you eloborate? It works fine for me with only table? Are you sure the javascript is without faults?

Anonymous said...

Can you please send code for displaying in two columns only?

nir said...

How can I hide the static view text from being displayed on screen below the pivot table view?

nir said...

How can I hide the static view text from being displayed on screen below the pivot table view?

John Minkjan said...

@Anonymous

set var intColumnNumbers = 2;

Regards

John

John Minkjan said...

@Nir

Set the CSS style to display:none

Unknown said...

Hi John,

Is it possible to combine 2 pivot tables displayed in the same compound layout.Both the pivot tables have the same formatting and similar columns, but because of some client formatting requirement i need to create 2 pivots and now am trying to combine them.

Regards,
Milind

John Minkjan said...

@Milind,

Much easier if you use a union all (combined by simliar request) and make only one pivt table

Friends said...

Hi john, i dont find any css stlye option for the static text - properties? please let me know where can i find it?

Thank you for your solution.

Thanks in advance
Mani.

Unknown said...

Hi John, do you probably have the code update for OBIEE 11g? It doesn't seem to work in 11g. Thanks!

Anonymous said...

Hi John,
Can you please post the code referred to the 11g, becouse the code does not work in 11g?

Anonymous said...

hi John,
I have a requirement to create a union with Col X, Col A in one report and Col X, Col B in 2nd report. Now the final results report should show Colx, Col A/B. Is this doable in OBIEE 11.1.1.6 ? Many thanks for your help