2016-04-19 39 views
0
<asp:GridView ID="grdDonationRequests" runat="server" SelectMethod="grdDonationRequests_GetData" AutoGenerateColumns="False" 
           AllowPaging="True" PagerSettings-Mode="NumericFirstLast" PageSize="10" DataKeyNames="DonationRequestID" ItemType="Tayf.Models.DonationRequest" 
           AllowSorting="true" Width="100%" CssClass=" table-striped table-condensed table table-bordered table-hover" meta:resourcekey="grdDonationRequestsResource1"> 

我試圖做到這一點如何在asp.net GridView上應用Datatable jQuery?

$(function() {    
     $("#<%=grdDonationRequests.ClientID%>").prepend(
$("thead>/thead>").append($(this).find("tr:first"))).dataTable({    
        }); 
       }); 

,但它給了我一個錯誤 Uncaught TypeError: Cannot read property 'className' of undefined

Update:- 

當我嘗試這樣做'$("#<%=grdDonationRequests.ClientID%>").dataTable({ "aaSorting": [] });'它給我任何錯誤也畫GridView控件的數據表,但它顯示作爲空的

+0

不清楚你在問什麼。你能詳細解釋一下嗎? –

+0

@PiyushKhatri我需要在我的asp.net gridview上應用數據表jquery插件,它使我能夠搜索,排序,分頁......等 –

回答

0

試試這個

$(function() {    
    $("#<%=grdDonationRequests.ClientID%>").dataTable({ 
    }); 
}); 

也期待在this答案

+0

當我試過這個''$(「#<%= grdDonationRequests.ClientID%> 「).GridviewFix()。dataTable({」aaSorting「:[]});' '它給了我沒有錯誤也將gridview作爲datatable,但顯示爲空 –

1

我在現在在做這事的過程。以下代碼是實際將gridview轉換爲數據表所需的全部內容:

$(document).ready(function() { 
var table = $('#your_gridview_id').DataTable(); 

希望這有助於!