title: Expand/Collapse DetailView in Telerik MVC Grid
body: <p>I´m trying to force javascript to collapse all other rows when expanding one of them, I just want to keep one row expanded at a time.  I´m fairly new to javascript so I hope anyone can point me in the right direction.</p>
  
  <p>I looked over this example I found but for some reason my code doesn´t collapse the rows:
  <a href="http://www.telerik.com/community/forums/aspnet-mvc/grid/expand-collapse-all-detailviews-in-a-grid.aspx" rel="nofollow">Expand/Collapse all DetailViews in a grid</a></p>
  
  <p>Shouldn´t I collapse the index like I´m doing in the javascript?</p>
  
  <p><strong>My Telerik Grid in MVC Razor View:</strong></p>
  
  <pre><code>&lt;div&gt;
  @(Html.Telerik().Grid&lt;RentableUnit&gt;()
             .Name("RentableUnits")
             .Columns(columns =&gt;
                          {
                              columns.Bound(e =&gt; e.UnitID).Hidden();
                              columns.Bound(e =&gt; e.Name).Width(800);
                              columns.Bound(e =&gt; e.IsExpanded).Hidden();
                          })
             .ClientEvents(events =&gt; events.OnRowDataBound("employees_onRowDataBound")
                                         .OnDetailViewExpand("unit_onDetailViewExpand")
                                         .OnDetailViewCollapse("unit_onDetailViewCollapse")
                                         .OnDetailViewExpand("toggleDetail")
                                         )
             .DetailView(details =&gt; details.ClientTemplate(
                 //stuff in template
             )
      .DataBinding(dataBinding =&gt; dataBinding.Ajax().Select("RentableUnits", "Home"))
      .Sortable()
  )
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>My Javascript:</strong></p>
  
  <pre><code>    function toggleDetail(e) {
          var grid = $(this).data('tGrid');
          grid.$rows().each(function (index) {
              //TODO: exclude the expanded row
              grid.collapseRow(index); //doesn´t collapse!
      });
  }
  </code></pre>