2017-01-03 10 views
0

ツリービューを展開し、ノードにスクロールして1つの関数にフォーカスすることは可能ですか?devExtreme TreeView Expand、ScrollTo、Focus

$("#buttonTest").dxButton({ 
    text: "Test", 
    onClick: function() { 

     editTreeView.expandItem(editTreeView.element().find(".dx-treeview-item")[0]) 

     var currentNode = $("#editTreeView").find("[data-item-id=" + 80 + "]"); 
     var scrollable = $("#editTreeView").find(".dx-scrollable").dxScrollable("instance"); 

     scrollable.scrollToElement(currentNode); 

     $("#editTreeView").find(".dx-treeview-node").removeClass("dx-state-focused"); 

     var currentNode = $("#editTreeView").find("[data-item-id=" + 80 + "]"); 
     currentNode.focus().addClass("dx-state-focused"); 

    } 
}); 

この例では、ツリーは最初のクリックで開かれ、2番目のクリックでスクロール/フォーカスされます。しかし、私はワンクリックでそれをしたい:)

ありがとう。

答えて

2

スクロール可能な高さの計算に関連する問題があるようです。

$("#buttonTest").dxButton({ 
    text: "Test", 
    onClick: function() { 
     //... 
     setTimeout(function() { 
      scrollable.scrollToElement(currentNode); 
     }, 300); 
    } 
}); 

このソリューションは、ハックのように見えますが、それでも))

私もfiddleを作成しました:あなたは、以下のようなsetTimeout機能を使用して、それを修正することができます。