Closed damirqa closed 3 years ago
Hello! I used jsTree in project. I have a code to create root
$json = []; if ($request->get('id') == '#') { $json = [ array( 'id' => 2, 'parent' => '#', 'text' => mb_convert_encoding('A', 'UTF-8'), ), array( 'id' => 3, 'parent' => '#', 'text' => mb_convert_encoding('B', 'UTF-8'), ), array( 'id' => 4, 'parent' => '#', 'text' => mb_convert_encoding('C', 'UTF-8'), ), array( 'id' => 5, 'parent' => '#', 'text' => mb_convert_encoding('D', 'UTF-8'), ), array( 'id' => 7, 'parent' => '#', 'text' => mb_convert_encoding('E', 'UTF-8'), ), ]; $rows = DB::select("SELECT [id], [shortname], [process_type], [pid] FROM [db].[record] WHERE [active] = 1 AND [pid] IS NULL"); foreach ($rows as $row) { $arr = array( 'id' => intval($row['id']), 'parent' => intval($row['process_type']), 'text' => mb_convert_encoding($row['shortname'], 'UTF-8'), 'children' => true, ); array_push($json, $arr); } }
`
The root is created based on the process type. And then lazy loading is based on a parent-child relationship. I get next line using lazy loading:
[{"id":3,"parent":91,"text":"somebody once told me","children":true}]
From this point on, I get a conflict between IDs of root and lazy loading: the root with the text 'B' is removed.
Is it possible to create and redraw a new node at the place of the click and not from the root?
Use unique IDs.
Hello! I used jsTree in project. I have a code to create root
`
The root is created based on the process type. And then lazy loading is based on a parent-child relationship. I get next line using lazy loading:
[{"id":3,"parent":91,"text":"somebody once told me","children":true}]
From this point on, I get a conflict between IDs of root and lazy loading: the root with the text 'B' is removed.
Is it possible to create and redraw a new node at the place of the click and not from the root?