Author Topic: Automatic leveling when you drag and drop tree structures  (Read 1066 times)

jeongkongmyeong

  • Newbie
  • *
  • Posts: 2
    • View Profile
Automatic leveling when you drag and drop tree structures
« on: October 07, 2019, 08:32:55 am »
hello :)

1. Automatic leveling when you drag and drop tree structures
① Select and drag a row

② drop a row

③ I would like to know how to change the level value automatically when dragging and dropping.


I will be waiting for your reply. Thank you. : )
Have a good one!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 4642
    • View Profile
Re: Automatic leveling when you drag and drop tree structures
« Reply #1 on: October 07, 2019, 09:49:28 am »
[ Only Pro members may read this post. ]

luckduck

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Automatic leveling when you drag and drop tree structures
« Reply #2 on: October 08, 2019, 03:55:06 pm »
Thank you for your reply !

Level is auto managed by treegrid while drag & drop and you are not supposed to directly change it.
-> I see.  I want to update automatically changed values.
    What methods can I use? (updateRow?)
« Last Edit: October 08, 2019, 04:04:14 pm by luckduck »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 4642
    • View Profile
Re: Automatic leveling when you drag and drop tree structures
« Reply #3 on: October 08, 2019, 05:06:25 pm »
[ Only Pro members may read this post. ]
« Last Edit: October 08, 2019, 05:33:39 pm by paramvir »

luckduck

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Automatic leveling when you drag and drop tree structures
« Reply #4 on: October 10, 2019, 10:15:05 am »
Thank you.

I'm trying to change  "unitLevel" after drag&drop.
"unitLevel" is pq_level + 1.

https://jsfiddle.net/yvfan0cb/1/




paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 4642
    • View Profile
Re: Automatic leveling when you drag and drop tree structures
« Reply #5 on: October 10, 2019, 11:36:04 am »
[ Only Pro members may read this post. ]
« Last Edit: October 10, 2019, 11:41:40 am by paramvir »

luckduck

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Automatic leveling when you drag and drop tree structures
« Reply #6 on: October 10, 2019, 01:36:45 pm »
Thanks for answer.

It works fine when there is only one leaf node.

How do I change the children of "MySQL", "Program Files" and "php" nodes with child nodes?


    moveNode: function(evt, ui){
       //debugger
      var grid = this;
      var Tree = grid.Tree();
      ui.args[0].forEach(function(rd){
         rd.unitLevel = rd.pq_level+1;
        grid.refreshCell({rowIndx: rd.pq_ri, dataIndx:'unitLevel'});

        // how to change children node ??
        Tree.eachChild(Tree.getNode(rd.pq_ri), function(node) {
           console.log("node.name", node.pq_level);
                 node.unitLevel = node.pq_level+1;
                grid.refreshCell({rowIndx: node.pq_ri, dataIndx:'unitLevel'});
        });

      });     
    },

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 4642
    • View Profile
Re: Automatic leveling when you drag and drop tree structures
« Reply #7 on: October 10, 2019, 09:58:59 pm »
[ Only Pro members may read this post. ]
« Last Edit: October 10, 2019, 10:02:24 pm by paramvir »