Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parse column data w/ dots for treeview 1

Status
Not open for further replies.

codecomm

Programmer
Joined
Feb 14, 2007
Messages
121
Location
US
I need to take the example data below and put it in a treeview control, but since there's no parent/child relationship and it's all in one column. I don't know how to approach this.

Our table as it sits right now, has the column (which is a primary key / nvarchar(100)) in question looking like:

D1
D1.01
D1.01.01
D1.01.01.02
D1.01.01.02.003
D1.01.02
D1.01.02.02
D1.01.02.03
E1
E1.01
E1.01.01
E1.01.01.02.003
E1.01.02
E1.01.02.02
E1.01.02.033
E1.01.02.04

So, I'm thinking I have to look for the first "dot" and pull out the characters before that for the first nodes:
D1
E1

....then look for the 2nd "dot" and pull every thing before that for the second drill down node if the user were to click on either "D1" or the "E1" nodes..and they'd see:
D1
D1.01
E1
E1.01

I think there's a strip or some function to do that, but I'm a bit stumped right now. I've seen some stuff on hierarchical data, but I'm not gettin' it.

Any suggestions are welcome!

Thanks!
 
Assuming you can use test strings for node IDs, it's easy. Each node's parent is the part up to the last dot. If there is no dot, there's no parent (or the parent is the root node).

So all parents would be

Left(NodePosition, Len(NodePosition) - CharIndex('.', Reverse(NodePosition) + '.')

[COLOR=black #d0d0d0]My alarm clock causes time travel. When I hit snooze, no apparent time passes before the alarm sounds again, but the universe has in fact moved forward through time by ten minutes![/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top