2016-09-19 30 views
-1

不工作我使用jQuery UI排序,使我的表網格排序。該代碼不顯示任何錯誤,但排序功能似乎沒有工作。通過這個我的意思是我的元素不重新排序。我從來沒有在mvc(views/razor)項目中使用這種方法。jQuery的排序有桌子和TR寬度aps.net MVC視圖

將不勝感激,如果任何人都可以給我一些指導或幫助。

謝謝。

script type="text/javascript"> 

$('td, th', '#MenuItem').each(function() { 
    var cell = $(this); 
    cell.width(cell.width()); 
}); 

$('#MenuItem tbody').sortable().disableSelection(); 

<table id = "MenuItem" class="promo full-width alternate-rows" style="text-align: center;"> 
      <tr> 
       <th>Prode Code 
       </th> 
       <th>ProdeTemplate 
       </th> 
       <th>Description <!-- JACK EDIT --> 
       </th> 
       <th>Action</th> 
      </tr> 
      <tbody> 
      @foreach (var item in Model.IndexListitem) 
      { 


       <tr> 
        <td class="center-text"> 
         @Html.DisplayFor(modelItem => item.ProductCode) 
        </td> 
        <td> 
         @Html.DisplayFor(modelItem => item.ProdeTemplate.Description) 
        </td> 
        <td> 
         @Html.DisplayFor(modelItem => item.Description) 
        </td> 

        <td class="center-text nowrap"> 
         @Html.ActionLink(" ", "Edit", new { id = item.ProdeID }, new { title = "Edit", @class = "anchor-icon-no-text edit" }) 
         @Html.ActionLink(" ", "Details", new { id = item.ProdeID }, new { title = "Details", @class = "anchor-icon-no-text details" }) 
         @Html.ActionLink(" ", "Delete", new { id = item.ProdeID }, new { title = "Delete", @class = "anchor-icon-no-text delete" }) 
        </td> 
       </tr> 

      } 

       </tbody> 

     </table> 

回答

0

如果我正確理解你的問題/代碼,你想整個錶行可拖動?

,它是在MVC項目沒有關係的事實。

務必確保該網頁是爲你準備好開始使用(document).ready()操作元件。

$(document).ready(function() { 
    $('#MenuItem tbody').sortable().disableSelection(); 
}); 

這是我想你試圖實現的working jsFiddle

相關問題