jQuery UI Widgets Forums Navigation Tree Tree not refreshing data

This topic contains 5 replies, has 2 voices, and was last updated by  Dimitar 10 years, 5 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • Tree not refreshing data #53559

    realtek
    Participant

    Hi,

    I have a jqxTree which is bound to a data source using a dataAdapter.

    After I make some changes to the database (which is the source). I then refresh the jqxTree by specifying the datasource again.

    I can see from a web debugger that the json query is called again and the response reflects the changes but the tree is not updated.

    This is my code which is rebinding the data

    
      function refreshTree() {
            var dataAdapter = new $.jqx.dataAdapter(source);
            dataAdapter.dataBind();
            $( '#jqxTree').jqxTree({ source: records });
        }
    

    Because I have quite a few records in the tree its taking me back to the top of the tree once its complete so I know something is refreshed.

    I have done this many times on the rest of my site. The only difference is, this tree contains three levels.

    I am at a loss now!

    Tree not refreshing data #53561

    Dimitar
    Participant

    Hello realtek,

    You set the tree source to records. Are you sure this variable is refreshed? It does not seem so from your code. Moreover, it is possible that the data bind has not yet been completed by the time you refresh the tree. In that case, you should call the refresh in the data adapter’s loadComplete callback function.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Tree not refreshing data #53570

    realtek
    Participant

    Thanks Dimitar,

    Doing a combination of both your solutions resolved the issue.

    I put a refresh for the Tree inside loadComplete and also set the records variable again.

    Each of these on there own didn’t make a difference so it looks like there were two issues.

    Is it possible to stop the tree from jumping back to the top when its refreshed?

    Thanks

    Tree not refreshing data #53625

    Dimitar
    Participant

    Hi realtek,

    The tree cannot be stopped from going to the top when refreshed, but you can call the method ensureVisible to scroll it to a particular item afterwards.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Tree not refreshing data #53708

    realtek
    Participant

    Hi Dimitar,

    I have tried setting this but it doesn’t seem to go back to the element that was selected.

    Would you set the item in a variable before the refresh happens and then set ensureVisible after the refresh or before?

    Here is my code so far… also, there is no index on a Tree from what I understand so is ‘selectedItem’ returning the ‘element’ that is needed with ensureVisible like the documentation says?

    //Reload Tree Here
    var selectedItem = $(“#jqxTree”).jqxTree(‘selectedItem’);
    var dataAdapter = new $.jqx.dataAdapter(source);
    dataAdapter.dataBind();
    $(‘#jqxTree’).jqxTree({ source: records });
    $(“#jqxTree”).jqxTree(‘ensureVisible’, selectedItem);

    Tree not refreshing data #53718

    Dimitar
    Participant

    Hi realtek,

    This would not work because by the time you call ensureVisible the tree has re-rendered and the selected item (i.e. its HTML element) no longer exists. You would have to make the selection after the tree has been refreshed.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.