>Hi all
>
>I have this table which is displyed as a TreeView and is self-joined. The fields are as under:
>
>iID - Unique ID
>iPID - Parent record's ID
>cName
>cCode - Code field for which this query is about
>iSrNo - related to code field
>
>This will have records as below:
>
>1 0 ABC 001 1
>2 1 ABCChild1 001001 1
>3 1 ABCChild2 001002 2
>4 1 ABCChild3 001003 3
>5 3 ABCGranChildof2 001002001 1
>so on
>
>
>This code is not a specification, but I felt that it may be required, but then it has it's own processing and management overheads. The reason I had thought this would be necessary is because, I had felt that when I report I can ask for a report based on cCode = "001" or cCode = "001002" and the node and all it's children will come up.
>
>Similarly the iSrNo field is to allow the user to change the display order of the children nodes like for eg. the user wants the ABCChild3 to preceed ABCChild2 then he can change the Sr. No. from 3 to 2 and 2 to 3 (I will modify cCode accordingly on save).
>
>Have I done it right or there are better ways to do and get the same results.
>
>Please advise.
Bhavbhuti,
IMHO on the long run this would be tedious and even defeat a simple treeview structure (NodeID,ParentID,NodeText). You might never know beforehand how much deep your grandchildren node would be. cCode field might quickly run out of space.
I suggest a structure like :
NodeID,ParentId,NodeText,Level (0-root,1,...N),RootId (rootNode ID of this node),OrderInGroup
Cetin