title: Kendo UI Treeview collapse all items and only expand current node
body: <p>I have a situation that has been bugging me for some time. I have a Kendo UI treeview in my project set up as described on <a href="http://demos.telerik.com/kendo-ui/web/treeview/events.html" rel="nofollow">http://demos.telerik.com/kendo-ui/web/treeview/events.html</a>. </p>
  
  <p>What I need to achieve is to say when I expand a node on the treeview, all the other nodes not in this branch should be collapsed and on this branch expanded. I have tried using the following code but unfortunately its going into an infinite loop.</p>
  
  <pre><code>&lt;div id="example" class="k-content"&gt;
              &lt;div id="treeview" class="demo-section" style="width: 200px"&gt;&lt;/div&gt;
              &lt;div class="demo-section"&gt;
                  &lt;h3 class="title"&gt;Console log
                  &lt;/h3&gt;
                  &lt;div class="console"&gt;&lt;/div&gt;
              &lt;/div&gt;
  &lt;script type="text/javascript"&gt;
  
          $(document).ready(function() {
  
                     function onExpand(e) {                        
                           e.preventDefault();
                           kendoTreeView.collapse('.k-item');
                           kendoTreeView.expand(e.node);                
                          }
  
                        $("#treeview").kendoTreeView({
                              dataSource: [
                                  { text: "Furniture", expanded: true, items: [
                                      { text: "Tables &amp; Chairs" },
                                      { text: "Sofas" },
                                      { text: "Occasional Furniture" }
                                  ] },
                                  { text: "Decor", items: [
                                      { text: "Bed Linen" },
                                      { text: "Curtains &amp; Blinds" },
                                      { text: "Carpets" }
                                  ] },
                                  { text: "Storage" }
                              ],
                          expand:OnExpand
                        });
                });
  &lt;/script&gt;
  </code></pre>
  
  <p>Please help.</p>
  
  <p>Thanks</p>