JsTree v1.0 - How to manipulate effectively the data from the backend to render the trees and operate correctly?

I'm using JsTree stable version from Github and I'm trying the add the logic for it to be dynamic enough to hold the data in a table for each category whether a discussion, file, a contact to be tagged, so basically is a tagging system.

My question is basically, if the following DB design can be preventing to do the 'Copy' operation:

          `id` int(11) NOT NULL AUTO_INCREMENT,
          `parent_id` int(11) NOT NULL DEFAULT '0',
          `user_id` int(11) NOT NULL DEFAULT '0',
          `label` varchar(16) DEFAULT NULL,
          `position` bigint(20) unsigned NOT NULL DEFAULT '0',
          `left` bigint(20) unsigned NOT NULL DEFAULT '0',
          `right` bigint(20) unsigned NOT NULL DEFAULT '0',
          `level` bigint(20) unsigned NOT NULL DEFAULT '0',
          `type` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
          `h_label` varchar(16) NOT NULL DEFAULT '',
          `fulllabel` varchar(255) DEFAULT NULL,
          UNIQUE KEY `uidx_3` (`id`),
          KEY `idx_1` (`user_id`),
          KEY `idx_2` (`parent_id`)
        ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

The original looks like this instead:

        CREATE TABLE IF NOT EXISTS `tree` (
          `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
          `parent_id` bigint(20) unsigned NOT NULL,
          `position` bigint(20) unsigned NOT NULL,
          `left` bigint(20) unsigned NOT NULL,
          `right` bigint(20) unsigned NOT NULL,
          `level` bigint(20) unsigned NOT NULL,
          `title` text CHARACTER SET utf8 COLLATE utf8_unicode_ci,
          `type` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
          PRIMARY KEY (`id`)
        ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=13 ;

        INSERT INTO `tree` (`id`, `parent_id`, `position`, `left`, `right`, `level`, `title`, `type`) VALUES
        (1, 0, 2, 1, 14, 0, 'ROOT', ''),
        (2, 1, 0, 2, 11, 1, 'C:', 'drive'),
        (3, 2, 0, 3, 6, 2, '_demo', 'folder'),
        (4, 3, 0, 4, 5, 3, 'index.html', 'default'),
        (5, 2, 1, 7, 10, 2, '_docs', 'folder'),
        (6, 1, 1, 12, 13, 1, 'D:', 'drive'),
        (12, 5, 0, 8, 9, 3, 'zmei.html', 'default');

We are using JSON to pass the data back to the server in where I'm adding some small logic to get the min and max values for records that matches the user_id. That way I'm updating on each interaction with the operations the first two record values for the 'left' and 'right'. Can someone please help me with understanding why if every other operation works, the Copy / Paste doesn't? Thanks.

Answers


it ended up being at the source code deleted previously, I mean the fix is in many places to render only the records based on the user that is currently logged into the system, but merely these lines should be credited to Ivan Bozhanov which in the image below provided with the offending line. hope that it helps anyone out there that is stuck at that same spot. We are making reference to another table with the user_id that matches the records with nested set

            if($is_copy) {
                        $sql[] = "" . 
                            "INSERT INTO `".$this->table."` (" . 
                                "`".$this->fields["parent_id"]."`, " . 
                                "`".$this->fields["position"]."`, " . 
                                "`".$this->fields["left"]."`, " . 
                                "`".$this->fields["right"]."`, " . 
                                "`".$this->fields["level"]."` ," . 
                                                        "`user_id`," . 
                                                        "`label`" . 
                            ") " . 
                                "SELECT " . 
                                    "".$ref_id.", " . 
                                    "`".$this->fields["position"]."`, " . 
                                    "`".$this->fields["left"]."` - (".($idif + ($node[$this->fields["left"]] >= $ref_ind ? $ndif : 0))."), " . 
                                    "`".$this->fields["right"]."` - (".($idif + ($node[$this->fields["left"]] >= $ref_ind ? $ndif : 0))."), " . 
                                    "`".$this->fields["level"]."` - (".$ldif."), `user_id`,`label` " . 
                                "FROM `".$this->table."` " . 
                                "WHERE " . 
                                    "`user_id`= ".$uid." AND `".$this->fields["id"]."` IN (".implode(",", $node_ids).") " . 
                                "ORDER BY `".$this->fields["level"]."` ASC";
                    }

Need Your Help

Why the input and the select do not get the same width?

html css

I have a table with two rows. The first row contains an input and the second row contains a select. Even though I have set their widths to be 100%, the select box is a few pixels smaller than the i...

Pop Window's attributes not changing in Javascript

javascript html google-chrome popupwindow

I tried the following simple pop-up code obtained from here and slightly modified-