vakata / jstree

jquery tree plugin
http://jstree.com
MIT License
5.15k stars 1.38k forks source link

search throws error if data json contains boolean values - jsTree - v3.3.10 #2434

Closed bhatsandeep closed 4 years ago

bhatsandeep commented 4 years ago

if the data contains values like {"somedata": true} it throws an error "Uncaught TypeError: a.toLowerCase is not a function" if we try to perform search on the tree

search = function (text) { text = options.caseSensitive ? text : text.toLowerCase();

should be something like

search = function (text) { text = options.caseSensitive ? text : (text.toString()).toLowerCase();

vakata commented 4 years ago

I will need to see your full config, but this must be something you have configured, as jstree defaults to only searching in the text content of the node. Please share your config so that I can help.

bhatsandeep commented 4 years ago

Sharing the details as below:

$(c_tree).jstree({ "core" : { "animation" : 0, "multiple" : false, "check_callback" : true, "themes" : { "stripes" : true }, "data" : eval(jsondata) }, "plugins" : [ "changed", "contextmenu", "dnd", "search", "state", "types", "wholerow" ], "search": { "case_sensitive": false, "show_only_matches": true }, "types" : { "#" : { "max_children" : 1, "max_depth" : 6, "valid_children" : ["root"] }, "root" : { "icon" : "/img/folder.svg", "valid_children" : ["default"] }, "default" : { "icon" : "/img/folder.svg", "valid_children" : ["default"] } } });

jsondata = [{'id': '1', 'parent': '#', 'text': 'schedule', 'data': {}}, {'id': '2', 'parent': '1', 'text': 'ide-init', 'data': {'1': {'key': 'function', 'value': '_init'}, '2': {'key': 'startup', 'value': True}}}, {'id': '3', 'parent': '#', 'text': 'variables', 'data': {'1': {'key': 'IDE_GOOGLE_AUTH_KEY', 'value': '12342342343124234'}, '2': {'key': 'IDE_GOOGLE_AUTH_SECRET', 'value': '7vn5YXvpncpeweijkerj34-'}}}]

vakata commented 4 years ago

Seems to work just fine: https://jsfiddle.net/dr0atzqw/1/

bhatsandeep commented 4 years ago

Sorry for the delayed response. I found the issue was with my data at another place.

Appreciate your help.