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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TreeView multiple selection exceeds nesting limit 1

Status
Not open for further replies.

Patricia Cu

Programmer
Mar 16, 2018
30
0
0
CA
Hello,
I have a tree control that uses recursion to lookup data in the database to create child nodes and at the same time set them to Checked when multiple selection of nodes is enabled.
The code looks like the sample provided on another thread with similar title to this one. Basically: TREE.CHECKNODE event calls a custom method in its parent container/form, and this method calls itself - code shown below.

We apply the same logic to several tables that have the same hierarchy.
However, we recently encountered an issue with a new table that follows the same hierarchy as the other ones.
We hit the Insufficient Stack Space message for one particular set of codes in the new table.
We already tried setting the STACKSIZE value to 64000 in the config.fpw file, but that did not help.


Could anyone provide any other suggestions on how to address this issue?

Thank you for any help you can provide.

Regards,
Patricia Cu

Code:
*** OLE Control CHECKNODE Event ***
LPARAMETERS node
local lval
thisform.startwait
lval = node.checked
with this.parent.parent
   if type('node.child.key') <> 'U'
      .checknodes(node.child,lval)
   endif
   if lval 
      .btnok.enabled = .t.
   endif
endwith
thisform.endwait
node = .f.

Code:
*******parent.parent container CHECKNODES method*****************
lpara node, lval
this.gtree1.treecontrol.expand(node.parent)
node.checked = lval
if type('node.child.key') <> 'U'
   this.checknodes(node.child,lval)
endif
if type('node.next.key') <> 'U'
   this.checknodes(node.next,lval)
endif
node = .f.


Code:
********parent.parent container EXPAND method********
**setup sql statement
**run sql statement and create nodes with the resulting cursor
**also set attributes for the nodes

with this.nodes
   ogx.odbm.execsql(thisform.datasessionid,sSql,'branch')
   msele = sele()
   select('branch')
      scan
         if dispcode = code
            cTitle = nvl(alltrim(dispcode),' ')+'  '+alltrim(desc1)+'  '+alltrim(str(lev))
         else
            cTitle = substr(alltrim(own),1,len(alltrim(own)))+'  '+nvl(alltrim(dispcode),' ')+'  '+alltrim(desc1)+'  '+alltrim(str(lev))
         endif
         mnode = .Add(mRK+own,4,mRK+code, alltrim(cTitle))
         mnode.bold = iif(dtflg = 1 and this.parent.parent.seltyp<3,.t.,.f.)         
         if type('mnode.tag') = "C"
               if this.parent.parent.seltyp > 2 
                  if dtflg = 1
                     mnode.tag = substr(alltrim(own),1,len(alltrim(own)))
                  else
                     mnode.tag = dispcode
                  endif
               else
                  if dtflg = 1
                     mnode.tag = dispcode
                  else
                     mnode.tag = ""
                  endif
               endif
         endif
      endscan
   select(msele)
endwith
mnode = .f.
 
How many records (nodes) are you dealing with? Regardless, the general advice for treeviews is to only populate child nodes when the parent is expanded. Saves a lot of time on form open and means that many never get populated since users don't usually expand every parent. This paper by Doug Hennig shows how to do that:
Tamar
 
You might have a circular reference, eg a node referencing itself as child or any parent level node as child node.
 
Hi Tamar, we do populate child nodes until the parent is expanded. See vfp code box for *****parent.parent container CHECKNODES method*****

Hi Olaf, not sure about the circular reference. The hierarchy structure in this table ensures every code has a hierarchy level, owner code and reporting code assigned to it. The only difference that we noticed in the node that triggers the error is the fact that it contains over 1000 child nodes. We ended up testing for the number of child nodes of a selected node prior to recursively setting their checkboxes to Checked. We then skip those nodes and issue a message. Not very pretty but it prevents the system from crashing, plus we were on a deadline.

Thank yo for your feedback Olaf and Tamar!

Regards,
Patricia Cu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top