J
jeet_sen
Hi,
I have created a table colelcting data from an XML source.
After I built the whole table I ahve given user options to filter out
columns from the table.
For this I have collected all the column values of the table in a
select list box.
Depending on what user selects from the selct list I am displaying the
corresponding columns and hiding the columns which the user has not
selected fromt the list.
Now after the table is generated if now user selects multilple values
from the list, the table displays the corresponding data but all on
same column , i.e the table has only 1 column but will multiple values.
Code snippet to create table
for (i = 0 ; i < dt[0].childNodes.length ; i++) // dt is my XML query
result
{
.......
var data = dt[0].childNodes.nodeName.trim(); // data is my column
header value
var container = document.createElement('TH'); //creatinh header
element
container.setAttribute("id",data); //assigning
id same as column header name
}
Code snippet to show/hide columns in table
// allDetailCheckList.length = array of all the column header values in
the table
// detailCheckList = aray of column header selected by
user from list
for (i = 0 ; i < allDetailCheckList.length ; i++)
{
var th = document.getElementById(allDetailCheckList);
if (th)
{
if ( detailCheckList.grep(allDetailCheckList) == -1) // grep
function returns -1 if allDetailCheckList is not found in array
detailCheckList. else returns the index.
th.style.display = "none";
else
th.style.display = "block";
}
}
Where I am going wrong ? Should I have to set some specific property
for the table created?
Regards,
Suvajit
I have created a table colelcting data from an XML source.
After I built the whole table I ahve given user options to filter out
columns from the table.
For this I have collected all the column values of the table in a
select list box.
Depending on what user selects from the selct list I am displaying the
corresponding columns and hiding the columns which the user has not
selected fromt the list.
Now after the table is generated if now user selects multilple values
from the list, the table displays the corresponding data but all on
same column , i.e the table has only 1 column but will multiple values.
Code snippet to create table
for (i = 0 ; i < dt[0].childNodes.length ; i++) // dt is my XML query
result
{
.......
var data = dt[0].childNodes.nodeName.trim(); // data is my column
header value
var container = document.createElement('TH'); //creatinh header
element
container.setAttribute("id",data); //assigning
id same as column header name
}
Code snippet to show/hide columns in table
// allDetailCheckList.length = array of all the column header values in
the table
// detailCheckList = aray of column header selected by
user from list
for (i = 0 ; i < allDetailCheckList.length ; i++)
{
var th = document.getElementById(allDetailCheckList);
if (th)
{
if ( detailCheckList.grep(allDetailCheckList) == -1) // grep
function returns -1 if allDetailCheckList is not found in array
detailCheckList. else returns the index.
th.style.display = "none";
else
th.style.display = "block";
}
}
Where I am going wrong ? Should I have to set some specific property
for the table created?
Regards,
Suvajit