Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
adding scrollbar to table
Rupesh_Mh
hey any one down there can help me creating tables with scroll bars
thanks in advance..
Find more posts tagged with
Comments
mwilliams
<p>Hi Rupesh_Mh,<br />
<br />
This post from the devShare shows how to use an iFrame to allow a table to be scrollable.<br />
<br />
<a class='bbc_url' href='
http://developer.actuate.com/community/forum/index.php?/files/file/735-add-a-table-with-a-fixed-header-row/'>Add
a table with a fixed header row - Tips & Tricks - BIRT Exchange</a></p>
be26019
Great Post. Thanks. Any ideas where I could find some javascript to make a table sortable by clicking each table header? I found the following code, but I'm not sure if I can use it or call it in BIRT. Thanks again.<br />
<br />
/**<br />
*<br />
* Sortable HTML table<br />
* <a class='bbc_url' href='
http://www.webtoolkit.info/'>http://www.webtoolkit.info/</a><br
/>
*<br />
**/<br />
<br />
function SortableTable (tableEl) {<br />
<br />
this.tbody = tableEl.getElementsByTagName('tbody');<br />
this.thead = tableEl.getElementsByTagName('thead');<br />
this.tfoot = tableEl.getElementsByTagName('tfoot');<br />
<br />
this.getInnerText = function (el) {<br />
if (typeof(el.textContent) != 'undefined') return el.textContent;<br />
if (typeof(el.innerText) != 'undefined') return el.innerText;<br />
if (typeof(el.innerHTML) == 'string') return el.innerHTML.replace(/<[^<>]+>/g,'');<br />
}<br />
<br />
this.getParent = function (el, pTagName) {<br />
if (el == null) return null;<br />
else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())<br />
return el;<br />
else<br />
return this.getParent(el.parentNode, pTagName);<br />
}<br />
<br />
this.sort = function (cell) {<br />
<br />
var column = cell.cellIndex;<br />
var itm = this.getInnerText(this.tbody[0].rows[1].cells[column]);<br />
var sortfn = this.sortCaseInsensitive;<br />
<br />
if (itm.match(/\d\d[-]+\d\d[-]+\d\d\d\d/)) sortfn = this.sortDate; // date format mm-dd-yyyy<br />
if (itm.replace(/^\s+|\s+$/g,"").match(/^[\d\.]+$/)) sortfn = this.sortNumeric;<br />
<br />
this.sortColumnIndex = column;<br />
<br />
var newRows = new Array();<br />
for (j = 0; j < this.tbody[0].rows.length; j++) {<br />
newRows[j] = this.tbody[0].rows[j];<br />
}<br />
<br />
newRows.sort(sortfn);<br />
<br />
if (cell.getAttribute("sortdir") == 'down') {<br />
newRows.reverse();<br />
cell.setAttribute('sortdir','up');<br />
} else {<br />
cell.setAttribute('sortdir','down');<br />
}<br />
<br />
for (i=0;i<newRows.length;i++) {<br />
this.tbody[0].appendChild(newRows
);<br />
}<br />
<br />
}<br />
<br />
this.sortCaseInsensitive = function(a,B) {<br />
aa = thisObject.getInnerText(a.cells[thisObject.sortColumnIndex]).toLowerCase();<br />
bb = thisObject.getInnerText(b.cells[thisObject.sortColumnIndex]).toLowerCase();<br />
if (aa==bb) return 0;<br />
if (aa<bb) return -1;<br />
return 1;<br />
}<br />
<br />
this.sortDate = function(a,B) {<br />
aa = thisObject.getInnerText(a.cells[thisObject.sortColumnIndex]);<br />
bb = thisObject.getInnerText(b.cells[thisObject.sortColumnIndex]);<br />
date1 = aa.substr(6,4)+aa.substr(3,2)+aa.substr(0,2);<br />
date2 = bb.substr(6,4)+bb.substr(3,2)+bb.substr(0,2);<br />
if (date1==date2) return 0;<br />
if (date1<date2) return -1;<br />
return 1;<br />
}<br />
<br />
this.sortNumeric = function(a,B) {<br />
aa = parseFloat(thisObject.getInnerText(a.cells[thisObject.sortColumnIndex]));<br />
if (isNaN(aa)) aa = 0;<br />
bb = parseFloat(thisObject.getInnerText(b.cells[thisObject.sortColumnIndex]));<br />
if (isNaN(bb)) bb = 0;<br />
return aa-bb;<br />
}<br />
<br />
// define variables<br />
var thisObject = this;<br />
var sortSection = this.thead;<br />
<br />
// constructor actions<br />
if (!(this.tbody && this.tbody[0].rows && this.tbody[0].rows.length > 0)) return;<br />
<br />
if (sortSection && sortSection[0].rows && sortSection[0].rows.length > 0) {<br />
var sortRow = sortSection[0].rows[0];<br />
} else {<br />
return;<br />
}<br />
<br />
for (var i=0; i<sortRow.cells.length; i++) {<br />
sortRow.cells
.sTable = this;<br />
sortRow.cells
.onclick = function () {<br />
this.sTable.sort(this);<br />
return false;<br />
}<br />
}<br />
<br />
}