65
Views
9
Comments
[ZTree Reactive] Is it possible to save the status of tree after drag and drop nodes?
ztree-reactive
Reactive icon
Forge asset by Pedro Neto
Application Type
Reactive

I'm using this Forge. 

I actually want to save the status of tree after drag and drop nodes.

I mean, let's say you drag some nodes and move them in a tree.


・the original status of tree


・I moved nodes and edit tree like this



But, when you refresh the screen after editting tree, or when you reopen the screen,

the tree becomes the original status. 

 I can't save the tree status like this.  I want it to save after editting a tree.

I wonder if we can't make this kind of "Save" function in this Forge component...

Do you have any ideas?

It'd be nice if you could give me how to make this happen.


Best,

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Tsubasa,

The ZTree is fed with data you provide, so if you want to "save" its status, you need to do that yourself. I assume there's some way to read the current content of the tree, so you can inspect it, and save that.

UserImage.jpg
Tsubasa Yoshikawa

Hi Kilian ,

Thanks. I'm not sure how to implement actions (Client , Server)to read the current content of the tree .

I wonder if it is hard to implement save logic towards this component.


Would you happen to know the way?


2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Tsubasa,

Checking the zTreeReactive module, it seems there's a GetTreeNodes action that you can use to retrieve the current tree.


UserImage.jpg
Tsubasa Yoshikawa


Hi Kilian , 

Thank you. 

I created save button in Multiple Tree as an example, but I'm having difficulty making the logic to save the currrent tree data to Entity and update it.



* zTreeHomeData here is the entity I created for sample.

I just made the logic on client action of Save like below. But I'm not really confident in this and I suppose I'm missing somewhere.

Actually, I'm also not sure what "TreeId" here means....



Would you happen to know how to do this? I'd appreciate it if you could give some good advice on this part of save logic. Could you possibly lend me your expertise?

Regards,

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

TreeId is the widget id of the tree. You can check the demo app that you can also install from the Forge.

UserImage.jpg
Tsubasa Yoshikawa


Hi Kilian , 

Thanks.  I created Save action but it doesn't work...

I'm not sure where there is a problem in the logic of SaveonClick action. I made it like this.


After I moved some nodes in both trees, I clicked save button, then I refreshed the screen, but it wasn't saved actually.

Also, I checked the Entity in ServiceStudio to see if the data was updated but nothing changed.

 If I implemeted this, the data of Entity should be updated...


If you don't mind, could you possibly tell me where I'm missing and what kind of logic is right?

I'm attaching my zTreeReactice oml file.

I would be happy to get your advice.


Regards,


MyzTreeReactive.oml
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Tsubasa,

I'll try to see if I can take a look next week, currently a bit busy.

UserImage.jpg
Tsubasa Yoshikawa

Hi Kilian,

How is it coming along?

Did you notice any ideas and my mistakes from my oml ?



2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Tsubasa,

I took a cursory glance, but couldn't find anything obvious. Also, when I published your module I didn't get a tree, so I'll have to investigate further. Unfortunately, I'm still pretty busy with regular work :(.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.