/thead>").append($(this).fi-6ren">
gpt4 book ai didi

javascript - 如何在 ASP.NET GridView 上应用 Datatable jquery?

转载 作者:行者123 更新时间:2023-12-03 07:08:24 26 4
gpt4 key购买 nike

 <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">

我尝试这样做

    $(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 绘制为数据表但将其显示为空

最佳答案

我现在正在做这件事。以下代码是将 gridview 实际转换为数据表所需的全部代码:

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

希望这有帮助!

关于javascript - 如何在 ASP.NET GridView 上应用 Datatable jquery?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36713679/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com