[MSEide-MSEgui-talk] treeitemedit

classic Classic list List threaded Threaded
28 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[MSEide-MSEgui-talk] treeitemedit

mohamed hamza

How  to add a child item to a parent item. 


In the msuniverse there are examples but with a known numbers of nodes.


{
with tmynode(treeedit[0]) do begin
   caption:= 'AAAAA';
   add(3,tmynode);
   items[0].caption:= 'A0';
   items[1].caption:= 'A1';
   items[2].caption:= 'A2';
  end; }
  

I want to do 


with  tmynode [ nparent] do begin


add child ?



Regards


Med






------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mse
Administrator
On 07/25/2018 05:03 PM, mohamed hamza wrote:

> How  to add a child item to a parent item.
>
>
> In the msuniverse there are examples but with a known numbers of nodes.
>
> {
> with tmynode(treeedit[0]) do begin
>    caption:= 'AAAAA';
>    add(3,tmynode);
>    items[0].caption:= 'A0';
>    items[1].caption:= 'A1';
>    items[2].caption:= 'A2';
>   end; }
>
>
> I want to do
>
>
> with  tmynode [ nparent] do begin
>
>
> add child ?
>
I probably don't understand.
"
 ttreelistitem = class(tlistitem)
[...]
   procedure addchildren(const aitem: ttreelistitem);
                   //transfers children
   function add(const aitem: ttreelistitem): integer; overload;
                   //returns index, nil ignored
   procedure add(const aitems: treelistitemarty); overload;
   function add(const itemclass: treelistitemclassty = nil):
                                                 ttreelistitem; overload;
   procedure add(const acount: integer;
                            const itemclass: treelistitemclassty = nil;
                            const defaultstate: nodestatesty = []);
overload;
   procedure insert(aindex: integer; const aitem: ttreelistitem);
   procedure insert(const aitem: ttreelistitem; aindex: integer);
deprecated;
                               //use insert(aindex,aitem) above instead
"
are the add() possibilities of ttreelistitem.

"
   property count: integer read fcount;
"
returns the children count.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mohamed hamza

 begin
  if grid.rowcount = 0 then
 
  begin
   For i := 0 to 1 do
   begin
   grid.rowcount:=grid.rowcount+1;
   with tmynode(treeedit[i]) do begin
    caption:= chr(65+i);
     for j := 0 to 2  do begin
     add(1,tmynode );
     items[j].caption:= 'A' ;  these items are not added to tmynode(treeedit[i])
    end;end; end; end; end


Regards

De : Martin Schreiber <[hidden email]>
Envoyé : mercredi 25 juillet 2018 17:00
À : [hidden email]
Objet : Re: [MSEide-MSEgui-talk] treeitemedit
 
On 07/25/2018 05:03 PM, mohamed hamza wrote:
> How  to add a child item to a parent item.
>
>
> In the msuniverse there are examples but with a known numbers of nodes.
>
> {
> with tmynode(treeedit[0]) do begin
>    caption:= 'AAAAA';
>    add(3,tmynode);
>    items[0].caption:= 'A0';
>    items[1].caption:= 'A1';
>    items[2].caption:= 'A2';
>   end; }
>
>
> I want to do
>
>
> with  tmynode [ nparent] do begin
>
>
> add child ?
>
I probably don't understand.
"
 ttreelistitem = class(tlistitem)
[...]
   procedure addchildren(const aitem: ttreelistitem);
                   //transfers children
   function add(const aitem: ttreelistitem): integer; overload;
                   //returns index, nil ignored
   procedure add(const aitems: treelistitemarty); overload;
   function add(const itemclass: treelistitemclassty = nil):
                                                 ttreelistitem; overload;
   procedure add(const acount: integer;
                            const itemclass: treelistitemclassty = nil;
                            const defaultstate: nodestatesty = []);
overload;
   procedure insert(aindex: integer; const aitem: ttreelistitem);
   procedure insert(const aitem: ttreelistitem; aindex: integer);
deprecated;
                               //use insert(aindex,aitem) above instead
"
are the add() possibilities of ttreelistitem.

"
   property count: integer read fcount;
"
returns the children count.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mse
Administrator
On Wednesday 25 July 2018 19:28:26 mohamed hamza wrote:

> if grid.rowcount = 0 then
>
>   begin
>    For i := 0 to 1 do
>    begin
>    grid.rowcount:=grid.rowcount+1;
>    with tmynode(treeedit[i]) do begin
>     caption:= chr(65+i);
>      for j := 0 to 2  do begin
>      add(1,tmynode );
>      items[j].caption:= 'A' ;  these items are not added to
> tmynode(treeedit[i]) end;end; end; end; end

Works for me, please send a simple testcase which shows the problem

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mohamed hamza

I Had an error.  Deleting sta file corrected   this.


Regards.


Med




De : Martin Schreiber <[hidden email]>
Envoyé : jeudi 26 juillet 2018 06:38
À : [hidden email]
Objet : Re: [MSEide-MSEgui-talk] treeitemedit
 
On Wednesday 25 July 2018 19:28:26 mohamed hamza wrote:
> if grid.rowcount = 0 then
>
>   begin
>    For i := 0 to 1 do
>    begin
>    grid.rowcount:=grid.rowcount+1;
>    with tmynode(treeedit[i]) do begin
>     caption:= chr(65+i);
>      for j := 0 to 2  do begin
>      add(1,tmynode );
>      items[j].caption:= 'A' ;  these items are not added to
> tmynode(treeedit[i]) end;end; end; end; end

Works for me, please send a simple testcase which shows the problem

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mohamed hamza

I did not find a property level of a node. Do you think we do not need it?


Regards.


Med




De : mohamed hamza <[hidden email]>
Envoyé : jeudi 26 juillet 2018 15:11
À : General list for MSEide+MSEgui
Objet : Re: [MSEide-MSEgui-talk] treeitemedit
 

I Had an error.  Deleting sta file corrected   this.


Regards.


Med




De : Martin Schreiber <[hidden email]>
Envoyé : jeudi 26 juillet 2018 06:38
À : [hidden email]
Objet : Re: [MSEide-MSEgui-talk] treeitemedit
 
On Wednesday 25 July 2018 19:28:26 mohamed hamza wrote:
> if grid.rowcount = 0 then
>
>   begin
>    For i := 0 to 1 do
>    begin
>    grid.rowcount:=grid.rowcount+1;
>    with tmynode(treeedit[i]) do begin
>     caption:= chr(65+i);
>      for j := 0 to 2  do begin
>      add(1,tmynode );
>      items[j].caption:= 'A' ;  these items are not added to
> tmynode(treeedit[i]) end;end; end; end; end

Works for me, please send a simple testcase which shows the problem

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mse
Administrator
On 07/27/2018 11:18 AM, mohamed hamza wrote:
> I did not find a property level of a node. Do you think we do not need it?
>
Please use
"
 ttreelistitem = class(tlistitem)
[...]
   property treelevel: integer read ftreelevel;
"

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mohamed hamza

Hi Martin,

 I read msedatanodes.pas to find any method to give current node in the tree without success.


I tried  

grid.rowcount:=1;
node:=tmynode(treeedit[0]);
tmynode(treeedit[0]).caption:='ROOT';

current:=node.add(tmynode);
current.caption:='A1.'+inttostr(current.treelevel);
node:=current.add(tmynode);
node.caption:='A2.'+inttostr(node.treelevel);

In that way I got the tree:
   
   +ROOT

       +A1.1

          A2.2
Is there a simplest way? I tried with addchildren  ( current.addchildren( tmynode) no success.
 
the problem gets more complicated  when I used addchildren to specific node because it is in a previous level ?

for example :

before doing  c.addchildren(b)   do I have to search the parent

while    .......
  node:=node.parent;

I have never used tree object specially with mseIde.

I studied the examples  in mseuniverse sources. I learned the basic. But now I want to write something to save and restore
a tree from db file.

Regards.



  





De : Martin Schreiber <[hidden email]>
Envoyé : vendredi 27 juillet 2018 20:18
À : [hidden email]
Objet : Re: [MSEide-MSEgui-talk] treeitemedit
 
On 07/27/2018 11:18 AM, mohamed hamza wrote:
> I did not find a property level of a node. Do you think we do not need it?
>
Please use
"
 ttreelistitem = class(tlistitem)
[...]
   property treelevel: integer read ftreelevel;
"

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mse
Administrator
On Saturday 28 July 2018 17:33:06 mohamed hamza wrote:
> Hi Martin,
>
>  I read msedatanodes.pas to find any method to give current node in the
> tree without success.
>
What is the "current node"?

>
> I tried
>
> grid.rowcount:=1;
> node:=tmynode(treeedit[0]);
> tmynode(treeedit[0]).caption:='ROOT';
>
> current:=node.add(tmynode);
> current.caption:='A1.'+inttostr(current.treelevel);
> node:=current.add(tmynode);
> node.caption:='A2.'+inttostr(node.treelevel);
>
> In that way I got the tree:
>
>    +ROOT
>
>        +A1.1
>
>           A2.2
> Is there a simplest way?

Possible pseudo code:

procedure loadchildren(anode: <tchildnode>);
var
 node1: <tchildnode>
begin
 while there is data for children do begin
  node1:= <tchildnode.create>
  load node1 properties from data
  loadchildren(node1);
  anode.add(node1);
 end;
end;

begin
 rootnode:= <therootnode>.create;
 loadchildren(rootnode);
 <treeedit>.itemlist.add(rootnode);
[...]

> I tried with addchildren  ( current.addchildren(
> tmynode) no success.
>
node1.addchildren(<node2>) transfers the children of <node2> to <node1>

> the problem gets more complicated  when I used addchildren to specific node
> because it is in a previous level ?
>
> for example :
>
> before doing  c.addchildren(b)   do I have to search the parent
>
> while    .......
>   node:=node.parent;
>
I don't think so. What do you want to achieve?

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mohamed hamza

You propose a  recursive procedure


procedure loadchildren(anode: <tchildnode>);


Then while <..> loop must be deleted and replaced with (if not end of data)

is'nt it?


Regards.


De : Martin Schreiber <[hidden email]>
Envoyé : samedi 28 juillet 2018 16:20
À : [hidden email]
Objet : Re: [MSEide-MSEgui-talk] treeitemedit
 
On Saturday 28 July 2018 17:33:06 mohamed hamza wrote:
> Hi Martin,
>
>  I read msedatanodes.pas to find any method to give current node in the
> tree without success.
>
What is the "current node"?

>
> I tried
>
> grid.rowcount:=1;
> node:=tmynode(treeedit[0]);
> tmynode(treeedit[0]).caption:='ROOT';
>
> current:=node.add(tmynode);
> current.caption:='A1.'+inttostr(current.treelevel);
> node:=current.add(tmynode);
> node.caption:='A2.'+inttostr(node.treelevel);
>
> In that way I got the tree:
>
>    +ROOT
>
>        +A1.1
>
>           A2.2
> Is there a simplest way?

Possible pseudo code:

procedure loadchildren(anode: <tchildnode>);
var
 node1: <tchildnode>
begin
 while there is data for children do begin
  node1:= <tchildnode.create>
  load node1 properties from data
  loadchildren(node1);
  anode.add(node1);
 end;
end;

begin
 rootnode:= <therootnode>.create;
 loadchildren(rootnode);
 <treeedit>.itemlist.add(rootnode);
[...]

> I tried with addchildren  ( current.addchildren(
> tmynode) no success.
>
node1.addchildren(<node2>) transfers the children of <node2> to <node1>

> the problem gets more complicated  when I used addchildren to specific node
> because it is in a previous level ?
>
> for example :
>
> before doing  c.addchildren(b)   do I have to search the parent
>
> while    .......
>   node:=node.parent;
>
I don't think so. What do you want to achieve?

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mse
Administrator
On Saturday 28 July 2018 19:34:58 mohamed hamza wrote:

> You propose a  recursive procedure
>
>
> procedure loadchildren(anode: <tchildnode>);
>
>
> Then while <..> loop must be deleted and replaced with (if not end of data)
>
> is'nt it?
>
"if not end of child data of current node".

What do you want to achieve? How does the database structure look?

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mohamed hamza

At  this time I am working with an array of record:


type 
  part= record
   id:integer;
   cap:string;
   lv:integer;    //level of  node
 end;    
 
const parts : array[0..3] of part =

 (
   (id:1;cap:'AAA';lv:1),(id:2;cap:'A1';lv:1),
   (id:3;cap:'A2';lv:2),(id:4;cap:'A3';lv:1) ) ;

grid.rowcount:=1;
node:=tmynode(treeedit[0]);
tmynode(treeedit[0]).caption:='ROOT';

i:=0;

while not end of array do 
level :=parts[i].lv;

if level=node.treelevel then 
 current:=node.add(tmynode);
 else if level>node.treelevel then   // add new child
 node:=current.add(tmynode)
else  //  add node to corresponding parent in the tree.  ( my problem is here
....
....
....
( last node. added ).caption:=parts[i].cap;
inc(i);

end;  //end while

Do you understand what I want to do?

Later I wish to restore the tree from db file and why not uploading this example to mseuniverse.

Regards.

Med





De : Martin Schreiber <[hidden email]>
Envoyé : samedi 28 juillet 2018 17:59
À : [hidden email]
Objet : Re: [MSEide-MSEgui-talk] treeitemedit
 
On Saturday 28 July 2018 19:34:58 mohamed hamza wrote:
> You propose a  recursive procedure
>
>
> procedure loadchildren(anode: <tchildnode>);
>
>
> Then while <..> loop must be deleted and replaced with (if not end of data)
>
> is'nt it?
>
"if not end of child data of current node".

What do you want to achieve? How does the database structure look?

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mse
Administrator
On Sunday 29 July 2018 11:02:24 mohamed hamza wrote:
> At  this time I am working with an array of record:
>
>
[...]

I'll make an example.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mse
Administrator
On Sunday 29 July 2018 18:32:27 Martin Schreiber wrote:
> On Sunday 29 July 2018 11:02:24 mohamed hamza wrote:
> > At  this time I am working with an array of record:
>
> [...]
>
> I'll make an example.
>
Here:
https://gitlab.com/mseide-msegui/mseuniverse/tree/master/samples/db/tree
Needs MSEide+MSEgui current git master.
With a SQL database one probably would use tsqlresult and tsqlstatement
instead of a tlocaldataset.

Martin



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mohamed hamza
I am studying your source especially procedure tmainmo.insertingev(...)

Regards

Med

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mse
Administrator
On Tuesday 31 July 2018 22:15:05 mohamed hamza wrote:
> I am studying your source especially procedure tmainmo.insertingev(...)
>
In a SQL database one probably would use the method with nested sets.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mohamed hamza
In reply to this post by mohamed hamza

You suggest to  use tsqlresult but in this  case we  can not  set primary key  even less use  find ( nkey, ….)  ?

 

Regards

 

 

Med


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mse
Administrator
On Monday 06 August 2018 17:02:59 mohamed hamza wrote:
> You suggest to  use tsqlresult but in this  case we  can not  set primary
> key  even less use  find ( nkey, ....)  ?
>
There one uses the functions in the server with queries and SQL statements.
https://stackoverflow.com/questions/4048151/what-are-the-options-for-storing-hierarchical-data-in-a-relational-database
http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

Take a look to the method with nested sets.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mohamed hamza
In reply to this post by mohamed hamza

 

I think  we can do more with recursive query like:

 

with recursive CTE (nKey,caption ,nkeyp)  AS (

select id,name,pid FROM persons WHERE pid=:n

   union all

   select id,name,pid from persons

   join CTE t

   on t.nKey= persons.pid)

select * from cte ;

 

this sql statement  is  inserted to tsqlresult.sql .

I think that the procedure addchildren in mseuniverse example  is no longer valid?

 

We have  not access  to primary key  (id) to perform a find ().

 

Regards.

 

Med

 

Nb: Id is primary  key . pid is parent key .

 

 

 

 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] treeitemedit

mse
Administrator
On Monday 06 August 2018 19:16:53 mohamed hamza wrote:

> I think  we can do more with recursive query like:
>
> with recursive CTE (nKey,caption ,nkeyp)  AS (
> select id,name,pid FROM persons WHERE pid=:n
>    union all
>    select id,name,pid from persons
>    join CTE t
>    on t.nKey= persons.pid)
> select * from cte ;
>
AFAIK nested sets have a better performance for reading the tree.

> this sql statement  is  inserted to tsqlresult.sql .
> I think that the procedure addchildren in mseuniverse example  is no longer
> valid?
>
Correct, the order of the returned records and the returned values should
suffice to build the tree data.
How big is your tree? Is the data mostly static?

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
12