Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Hiding Table Rows [Thread Next] Re: Hiding Table RowsTo: NULL Date: 4/21/2006 11:14:00 AM
We got away from the Multiple table scheme, because we had a hard time
lining up the columns of the multiple tables. So we simply use a single
table, with parent child tags, and when the user collapse/expand a parent
item, we loop through the table and hide/show the child items.
Here is the code. What we do is pass the table id and row number to
collapse/expand to the toggle function.
function ToggleChildren(TableID,RowNum,bExpand)
{
var MyTable = document.getElementById(TableID);
ParentRow = MyTable.rows[RowNum];
var ParentID = ParentRow.getAttribute("id");
//Get selected row
for (var i = RowNum+1; i < MyTable.rows.length;i++)
{
MyRow = MyTable.rows[i];
var PID = MyRow.getAttribute("pid");
if (PID == ParentID)
{
if (bExpand == 'true')
{
MyRow.style.display = "";
}
else
{
MyRow.style.display = "none";
}
var AlreadyExpanded = MyRow.getAttribute("expanded");
if (bExpand == 'true' && AlreadyExpanded == 'true')
{
ToggleChildren(TableID,i,bExpand);
}
else if (bExpand == 'false')
{
ToggleChildren(TableID,i,bExpand);
}
}
}
}
function Toggle(TableID,RowNum)
{
//Get only one table for now
var MyTable = document.getElementById(TableID);
ParentRow = MyTable.rows[RowNum];
var Expanded = ParentRow.getAttribute("expanded");
if (Expanded == 'true')
{
Expanded = 'false';
}
else
{
Expanded = 'true';
}
//Set expanded flag to accordingly
ParentRow.setAttribute("expanded",Expanded);
ToggleChildren(TableID,RowNum,Expanded);
}
AliR.
"Scamjunk" <brahadambal@g...> wrote in message
news:1144819340.935210.105800@g......
> Hi,
>
> I am looking for a solution to a problem where I need to have a table
> format, and allow expansion or collapsing by the user. Since you
> already seem to have a solution ready, could you give guidelines to
> proceed? I have only been able to get everything into a single table.
> How to do it using multiple tables? how to get the multiple tables to
> synchronize? Please help.
>
> Thanks and warm regards,
> Scam.
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
