2015-02-23 20 views
1

我遇到了我的數據表格(http://www.datatables.net/manual/styling/bootstrap)gridview問題。當按下編輯按鈕時,gridview進入editmode。但是編輯的行成爲gridview中最後一行混淆了用戶。任何人都知道如何解決此問題?使用datatable bootstrap更新asp.net gridview中的行時。 editrow成爲最後一行

我的GridView:

<asp:GridView 
     ID="gv_cats" 
     AutoGenerateColumns="false" 
     runat="server" 
     DataKeyNames="ID" 
     CssClass="gvv_cats table table-striped table-bordered" 
     ShowHeaderWhenEmpty="true" 
     OnRowDeleting="gv_cats_RowDeleting" 
     OnRowEditing="gv_cats_RowEditing" 
     OnRowCancelingEdit="gv_cats_RowCancelingEdit">  
     <Columns> 
      <asp:CommandField ShowDeleteButton="true" ShowEditButton="true" /> 
      ....... 
     </Columns> 
    </asp:GridView> 

數據表,jQuery的構造函數:

var table = $(".gvv_cats").prepend($("<thead></thead>").append($(this).find("tr:first"))).dataTable({ 
     pagingType: 'full_numbers', 
     stateSave: true 
     }); 

    new $.fn.dataTable.FixedHeader(table); 

編輯:我也是開放的變通。我在想:gv_cats_RowEditing轉到gridview的最後一頁。但是,如何將代碼傳遞到數據表以轉到最後一頁?

回答

1

我不確定這是否適用於您的設置,但在我的情況下,編輯的行冒泡到表格的頂部。爲了讓行「編輯到位」我不得不禁用排序:

<script> 
 
    $(document).ready(function() { 
 
    $('#GridViewID').dataTable({ 
 
     "ordering": false, 
 
     stateSave: true 
 
    }); 
 
    }); 
 
</script>


這絕對是一個解決辦法,而不是一個固定的,但對我來說幸運用戶列的排序不是必需的。希望這可以幫助。

+0

不是100%的解決方案,因爲現在我的訂購不起作用。但它解決了這個問題。謝謝。 – 2015-03-30 05:30:19