|Re: How do you find a TreeItem index by searching the Data fields ? [message #462366 is a reply to message #462258]
||Tue, 11 October 2005 13:58
| Grant Gayed
Registered: July 2009
There isn't a way provided for locating a TreeItem based on its data.|
indexOf(TreeItem) does an identity match, so this won't help you.
Depending on your context there may be a better approach than running
through the full Tree each time though. For example, since your indexes
seem to be static, just keeping an array with index->TreeItem mappings could
provide a quicker solution.
"TJ Forshee" <firstname.lastname@example.org> wrote in message
> Here is my problem... I have a Tree and I am populating it from a
> When I add a TreeItem to the tree, I am setting its Data field with the
> index of the database record ( .setData(Integer.toString(dbIndex)) ).
> if I read a record from the database, and I know the index I am looking
> how can I easily find the TreeItem in the Tree ?
> I thought I could somehow use the .indexOf() function... but it requires a
> TreeItem as the parameter... but that is what I am looking for.... can I
> somehow create a 'dummy' TreeItem, do a setData of it to the index I am
> searching for, and call .indexOf(dummyTreeItem) ? or does the .indexOf
> require ALL fields fo the search item to match ?
> Hope I am making sense....
> Of course, I could create my own search function and just traverse the
> looking at each TreeItem's Data field.... just wondered if there was an
> easier way.
Powered by FUDForum
. Page generated in 0.09014 seconds