Quem nunca ouviu aquela frase "Mas no excel dá!"?
Então, no Cognos Também dá.
Segue abaixo a função, encontrei essa função para isso, mas não funcionava direito, mexi um pouco nela e ficou assim.
Modo de usar:
- Crie um html itém com a função abaixo dentro da tag <script language="javascript" type="text/javascript"> FUNÇÃO </script>.
- Crie um html itém como o conteúdo <span id="t1"> imediatamente antes da lista ou crosstab.
- Crie um html itém como o conteúdo </span> imediatamente depois da lista ou crosstab.
- No final do relatório crie um html itém com o conteúdo <script language="javascript" type="text/javascript"> ScrollableTable( 't1', 600,800, 1, 2)</script>
Utilize as variáveis freezeRow e freezeCol para definir onde será congelado.
Bom proveito!
------>>>> Código da função
function ScrollableTable (SpanId, tableHeight, tableWidth, freezeRow, freezeCol) {
var theSpan = document.getElementById(SpanId);
var tbl = theSpan.getElementsByTagName('table');
var tableEl = tbl[0];
initIEengine = function () {
this.containerEl.style.overflowY = 'auto';
this.containerEl.style.overflowX = 'auto';
// Trava linhas e colunas
var trs = tableEl.getElementsByTagName('tr');
for (x=0; x<trs.length; x++) {
var tds = trs[x].getElementsByTagName('td');
for (y=0; y<tds.length; y++) {
if(x <= freezeRow && y <= freezeCol) {
tds[y].style.position ='relative';
tds[y].style.setExpression("top", "this.parentElement.parentElement.parentElement.parentElement.scrollTop + 'px'");
tds[y].style.setExpression("left", "this.parentElement.parentElement.parentElement.parentElement.scrollLeft + 'px'");
tds[y].style.setExpression("zIndex", "'2'");
}
else if(x > freezeRow && y <= freezeCol) {
tds[y].style.position ='relative';
tds[y].style.setExpression("left", "this.parentElement.parentElement.parentElement.parentElement.scrollLeft + 'px'");
tds[y].style.setExpression("zIndex", "'1'");
}
else if(x <= freezeRow && y > freezeCol) {
tds[y].style.position ='relative';
tds[y].style.setExpression("top", "this.parentElement.parentElement.parentElement.parentElement.scrollTop + 'px'");
tds[y].style.setExpression("zIndex", "'1'");
}
}
}
eval("window.attachEvent('onresize', function () { document.getElementById('" + tableEl.id + "').style.visibility = 'hidden'; document.getElementById('" + tableEl.id + "').style.visibility = 'visible'; } )");
};
this.scrollWidth = 16;
this.originalHeight = tableEl.clientHeight;
this.originalWidth = tableEl.clientWidth;
this.newHeight = parseInt(tableHeight);
this.newWidth = tableWidth ? parseInt(tableWidth) : this.originalWidth;
tableEl.style.height = 'auto';
tableEl.removeAttribute('height');
this.containerEl = tableEl.parentNode.insertBefore(document.createElement('div'), tableEl);
this.containerEl.appendChild(tableEl);
this.containerEl.style.height = tableHeight;
this.containerEl.style.width = tableWidth;
var thead = tableEl.getElementsByTagName('thead');
thead = (thead[0]) ? thead[0] : null;
var tfoot = tableEl.getElementsByTagName('tfoot');
tfoot = (tfoot[0]) ? tfoot[0] : null;
var tbody = tableEl.getElementsByTagName('tbody');
tbody = (tbody[0]) ? tbody[0] : null;
if (document.all && document.getElementById && !window.opera) initIEengine();
}
Nenhum comentário:
Postar um comentário