jqueryajaxjstreejstree-search

how to change jstree search into ajax search


I'm trying to turn my jstree search into ajax search with the following configuration, my problem is, even though it sends "str" to the url and I receive the data in a json ["#id"] like, but jstree still does its normal search

// $.jstree.defaults.search.ajax = true;

$('#node_tree').jstree({
        'core' : {
        'data': fill_tree(),
    },
    "plugins": ["search", "state","themes"],
    'search': {
        'show_only_matches': true,
        'ajax': {
            'url': '/device/jstree',
            'dataType': 'json',
            'type': 'GET'
    }

My ajax is already working, and I need jstree to show my hard-coded result instead of its default search.


Solution

  • Just a reference for anyone with the same problem, even though jstree was sending ajax call correctly, it was showing it's own result instead of mine and I couldn't find any way to change this. So I was resigned to return a whole new JSON data and:

    $('#tree').jstree(true).settings.core.data = newJsonData;
    $('#tree').jstree(true).refresh();
    

    I know it was not the best option but it did the trick for the moment.