I need to use a searching function for my dynatree and so I found this workaround: [JQuery Dynatree - search node by name](https://stackoverflow.com/questions/12277797/jquery-dynatree-search-node-by-name)

However, I need to have it search only up until my expanded node delimiter.
(I am using jQuery ui-slider to dynamically set the expand delimiter).
Initially, I need it to search until my minExpandedLevel. And if I move the slider, the dynatree should show **only matching results** in expanded level equivalent to the slider value.

Trying to reset the minExpandLevel and reloading the dynatree just wont do as it returns all(even non-matching) nodes as result.

So I want to add a limit parameter to the search function like:

> 
> $(selector).dynatree("getRoot").search(pattern, limit);
> 
> 
> 

Does anybody know how to do this?

Here's my code:

**dynatree:**

```
$.ui.dynatree.nodedatadefaults["icon"] = false;

$("#resultTree").dynatree({
    minExpandLevel: 4,
    persist: false,
    classNames: {
        vline: "no-bg",
        connector: "",
        expander: "ui-helper-hidden"
    },
    children: myJsonData
});

```

**slider:**

```
timeout = false;
searchTerm = $("#searchText").val();
$("#treeslider").slider({
    min: minTick,
    max: maxTick,
    range: "min",
    slide: function (event, ui) {
        if (timeout) {
            clearTimeout(timeout);
        }
        timeout = setTimeout(function () {
            $("#resultTree").dynatree("getRoot").search(searchTerm, ui.value);
        }, 500);

    }
});

```