Author Topic: moveNodes issue in Tree  (Read 344 times)

jplevene

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 131
    • View Profile
moveNodes issue in Tree
« on: May 20, 2024, 02:15:42 am »
I am trying to manually move a node (not with DND, using only JS) and use the following code:

Code: [Select]
$("#grid").pqGrid("Tree").moveNodes({nodes:[rowData], parent:new_parentId});
When I do above I get a JS error in pqGrid "Uncaught TypeError: t.forEach is not a function"

What am I doing wrong?

jplevene

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 131
    • View Profile
Re: moveNodes issue in Tree
« Reply #1 on: May 20, 2024, 05:34:24 am »
Forgot to say, error is generated in "getUniqueNodes"

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6307
    • View Profile
Re: moveNodes issue in Tree
« Reply #2 on: May 20, 2024, 07:40:16 am »
Please correct the parameters.

Code: [Select]
var Tree = $("#grid").pqGrid('Tree');
Tree.moveNodes( [ rowData ], Tree.getNode( new_parentId ) );

jplevene

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 131
    • View Profile
Re: moveNodes issue in Tree
« Reply #3 on: May 21, 2024, 05:09:28 pm »
I tried that and it still causes the same error:

Code: [Select]
tree.moveNodes({nodes:[rowData], parent:parent});
I even tried:

Code: [Select]
tree.moveNodes({nodes:[ tree.getNode(rowData["ID"]) ], parent:tree.getNode(parent["ID"])});
« Last Edit: May 21, 2024, 05:15:31 pm by jplevene »

jplevene

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 131
    • View Profile
Re: moveNodes issue in Tree
« Reply #4 on: May 21, 2024, 05:51:04 pm »
I'm only moving one node from one parent to another BTW.

Even if I don't set parent and omit it I still get the error, so the error is caused by the "nodes" value.
« Last Edit: May 21, 2024, 05:54:30 pm by jplevene »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6307
    • View Profile
Re: moveNodes issue in Tree
« Reply #5 on: May 21, 2024, 07:11:36 pm »
There are no curly brackets {} in the parameters to moveNodes

Code: [Select]
var Tree = $("#grid").pqGrid('Tree');
Tree.moveNodes( [ rowData ], Tree.getNode( new_parentId ) );
« Last Edit: May 21, 2024, 07:13:37 pm by paramvir »