How to get second column content from tree

View: New views
3 Messages — Rating Filter:   Alert me  

How to get second column content from tree

by dvh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have this javascript code, which get content of first column of selected row from tree and displat it onto component with is="texID"(e.g. label).

function setText(treeID,textID)
{
  var tree = document.getElementById(treeID);
  var selection = tree.contentView.getItemAtIndex(tree.currentIndex);
  var text = selection.firstChild.firstChild.getAttribute("label");
  document.getElementById(textID).value = "You selected cell: " + text
}

But this always return first column of selected row. How can I get content of second column? Thanks.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
XUL News Wire      - http://xulnews.com
XUL Job Postings   - http://xuljobs.com
Open XUL Alliance - http://xulalliance.org 
_______________________________________________
xul-talk mailing list
xul-talk@...
https://lists.sourceforge.net/lists/listinfo/xul-talk

Re: How to get second column content from tree

by Christophe Charron-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi,
try  this :

var tree = document.getElementById(treeID);
  var selection = tree.contentView.getItemAtIndex(tree.currentIndex);
return tree.view.getCellText(selection,t.columns.getNamedColumn(textID))

--
Cordially,
Christophe Charron

2007/4/20, Dusan Halicky <dusan.halicky@...>:
Hi,

I have this javascript code, which get content of first column of selected row from tree and displat it onto component with is="texID"(e.g. label).

function setText(treeID,textID)
{
  var tree = document.getElementById(treeID);
  var selection = tree.contentView.getItemAtIndex(tree.currentIndex);
  var text = selection.firstChild.firstChild.getAttribute("label");
  document.getElementById(textID).value = "You selected cell: " + text
}

But this always return first column of selected row. How can I get content of second column? Thanks.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
XUL News Wire      - http://xulnews.com
XUL Job Postings   - http://xuljobs.com
Open XUL Alliance - http://xulalliance.org
_______________________________________________
xul-talk mailing list
xul-talk@...
https://lists.sourceforge.net/lists/listinfo/xul-talk



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
XUL News Wire      - http://xulnews.com
XUL Job Postings   - http://xuljobs.com
Open XUL Alliance - http://xulalliance.org 
_______________________________________________
xul-talk mailing list
xul-talk@...
https://lists.sourceforge.net/lists/listinfo/xul-talk

Re: How to get second column content from tree

by dvh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, it helps me to find the correct answer, here it is (tree.currentIndex instead of selection):

var tree = document.getElementById(treeID);
return tree.view.getCellText(tree.currentIndex,t.columns.getNamedColumn(textID))



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
XUL News Wire      - http://xulnews.com
XUL Job Postings   - http://xuljobs.com
Open XUL Alliance - http://xulalliance.org 
_______________________________________________
xul-talk mailing list
xul-talk@...
https://lists.sourceforge.net/lists/listinfo/xul-talk