Friday, January 22, 2010

OBIEE Horizontal Pivot Sections

From this: image to this:

image

Java script master Joe Betram showed us the way: http://forums.oracle.com/forums/thread.jspa?threadID=1009297&tstart=0 

Simple add a static text to your report:

image

Add Joe’s code:

<script type="text/javascript">
/* orignal code by Joe Betram
/* see:http:/*forums.oracle.com/forums/thread.jspa?threadID=1009297&tstart=0
*/
var debug =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');
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>");}
}

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>

Don’t forget to press the SET XML button before you save it!

 

Till Next Time

11 comments:

Mahesh Kumar Koramutla said...

Hi John,

This is a great tip!. Is there any way to limit the number of tables horizontally. ie. if I have 7 tabels to be presented horizonatally, can I split it into groups of 3 or more.

Any tips would be helpful.

Thanks
mahesh

John Minkjan said...

@ Masesh

Have a look here :
http://obiee101.blogspot.com/2010/01/obiee-horizontal-pivot-sections-part-2.html

regards

Mahesh Kumar Koramutla said...

Hi John,

Thanks for this, but the code is working only on Firefox, but not on IE7.

Any way to make it work on IE aswell.

Many Thanks again
Mahesh

John Minkjan said...

@ Masesh

fixed the code in http://obiee101.blogspot.com/2010/01/obiee-horizontal-pivot-sections-part-2.html

Regards

Audrina Majella said...

Though the code were great i think there are some things that needs to be fix first for it to more reliable. After that it might give some pointers on giving business transformation.

John Minkjan said...

@Audrina,

Please feel free to make an improvement suggestions.

Regards

Anonymous said...

John,

This solution works great,But once the report is downloaded into excel or power point , the formatting is lost. Is there a way to enforce this
Thanks
K

John Minkjan said...

@K

Not that I'm aware of, OBIEE has several issues with it's formatting when exporting to excel.

Regards

John

BASS said...

Hi John ,

I was tried this but where can i put the static text before or after the reports. i tried both the ways but the alignment was not done....


Thanks,
Srini

Consultoria RH said...
This comment has been removed by a blog administrator.
John Minkjan said...

@Srini,

in a textbox on your dashboard page

regards

John