C# 我想使用jQuery数据表,但我';我犯了一个错误

C# 我想使用jQuery数据表,但我';我犯了一个错误,c#,jquery,asp.net,model-view-controller,datatable,C#,Jquery,Asp.net,Model View Controller,Datatable,我想用jQueryDataTable进行多列过滤,但我遇到了一个错误,我不知道如何解决 错误: $(…)DataTable不是函数类型错误:$(…)。DataTable不是函数 未捕获的TypeError:无法读取未定义的属性“column” 你能帮我解决这个错误吗 我的HTML代码 @using MvcOnlineTicariOtomasyon.Models.Siniflar; @model List<Urun> @{ ViewBag.Title = "Index

我想用jQueryDataTable进行多列过滤,但我遇到了一个错误,我不知道如何解决

错误: $(…)DataTable不是函数类型错误:$(…)。DataTable不是函数 未捕获的TypeError:无法读取未定义的属性“column”

你能帮我解决这个错误吗

我的HTML代码

@using MvcOnlineTicariOtomasyon.Models.Siniflar;
@model List<Urun>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}



<br />
<table id="example" class="display table table-hover" style="width:100%">
    <thead>
        <tr class="table-active">
            <th>ID</th>
            <th>Ürün</th>
            <th>Marka</th>
            <th>Stok Adedi</th>
            <th>Alış Fiyatı</th>
            <th>Satış Fiyatı</th>
            <th>Kategori</th>
            <th>Görsel</th>
            <th width="10%">Güncelle</th>
            <th>Sil</th>
        </tr>
    </thead>
    @foreach (var u in Model)
    {
        <tbody>
            <tr>
                <td id="i">@u.UrunId</td>
                <td>@u.UrunAd</td>
                <td>@u.Marka</td>
                <td>@u.Stok</td>
                <td>@u.AlisFiyat ₺</td>
                <td>@u.SatisFiyat ₺</td>
                <td>@u.Kategori.KategoriAd</td>
                <td>@u.UrunGorsel</td>
                <td width="10%"><a href="/Urun/UrunGetir/@u.UrunId" class="btn btn-warning">Güncelle</a></td>
                <td><a href="/Urun/UrunSil/@u.UrunId" class="btn btn-danger">Sil</a></td>
            </tr>
        </tbody>
    }
</table>
<a href="/Urun/YeniUrun/" class="btn btn-primary">Ürün Ekle</a>

<link href="~/dosya/fixedHeader.dataTables.min.css" rel="stylesheet" />
<link href="~/dosya/jquery.dataTables.min.css" rel="stylesheet" />

<script src="~/dosya/jquery-3.5.1.js"></script>
<script src="~/dosya/jquery.dataTables.min.js"></script>
<script src="~/dosya/dataTables.fixedHeader.min.js"></script>

<script>
    $(document).ready(function () {
        // Setup - add a text input to eenter code hereach footer cell
        $('#example thead tr').clone(true).appendTo('#example thead');
        $('#example thead tr:`enter code here`eq(1) th').each(function (i) {
            var title = $(this).text();
            $(this).html('<input type="text" placeholder="' + title + ' Ara" />');

            $('input', this).on('keyup change', function () {
                if (table.column(i).search() !== this.value) {
                    table
                        .column(i)
                        .search(this.value)
                        .draw();
                }
            });
        });

        var table = $('#example table').DataTable({
            orderCellsTop: true,
            fixedHeader: true
        });
    });

</script>
@使用MvcOnlineTicariOtomasyon.Models.Siniflar;
@模型列表
@{
ViewBag.Title=“Index”;
Layout=“~/Views/Shared/_AdminLayout.cshtml”;
}

身份证件 Ürün 马尔卡 斯托克·阿德迪 艾尔菲亚特 星期六 卡泰戈里 格塞尔 甘塞尔 Sil @foreach(模型中的var u) { @u、 乌鲁尼 @u、 乌鲁纳德 @u、 马尔卡 @u、 斯托克 @u、 阿里斯菲亚特₺ @u、 满足感₺ @u、 卡泰戈里,卡泰戈里亚德 @u、 漆红漆 } $(文档).ready(函数(){ //设置-将文本输入添加到每个页脚单元格的输入代码中 $('#example thead tr').clone(true).appendTo('#example thead'); $('#示例thead tr:'在此处输入代码'eq(1)th')。每个(函数(i){ var title=$(this.text(); $(this.html(“”); $('input',this).on('keyup change',function(){ if(table.column(i).search()!==此.value){ 桌子 .第(i)栏 .search(此.value) .draw(); } }); }); 变量表=$(“#示例表”).DataTable({ 是的, fixedHeader:true }); });
试试这段代码

我已将此代码
#示例表
替换为
#示例
。因为您的表ID是“#示例”


$(文档).ready(函数(){
//设置-将文本输入添加到每个页脚单元格的输入代码中
$('#example thead tr').clone(true).appendTo('#example thead');
$('#示例thead tr:'在此处输入代码'eq(1)th')。每个(函数(i){
var title=$(this.text();
$(this.html(“”);
$('input',this).on('keyup change',function(){
if(table.column(i).search()!==此.value){
桌子
.第(i)栏
.search(此.value)
.draw();
}
});
});
变量表=$('#示例')。数据表({
是的,
fixedHeader:true
});
});

?错误是什么?$(…)DataTable不是函数类型错误:$(…)。DataTable不是函数未捕获类型错误:无法读取未定义共享html的属性“列”。您是否包含数据库库文件?谢谢。我做了,但什么也没改变。你能给我分享html代码吗?我添加了html代码。fiddle link感谢您的帮助,它在您发送的链接上有效,但在我的项目中无效。
<script>
    $(document).ready(function () {
        // Setup - add a text input to eenter code hereach footer cell
        $('#example thead tr').clone(true).appendTo('#example thead');
        $('#example thead tr:`enter code here`eq(1) th').each(function (i) {
            var title = $(this).text();
            $(this).html('<input type="text" placeholder="' + title + ' Ara" />');

            $('input', this).on('keyup change', function () {
                if (table.column(i).search() !== this.value) {
                    table
                        .column(i)
                        .search(this.value)
                        .draw();
                }
            });
        });

        var table = $('#example').DataTable({
            orderCellsTop: true,
            fixedHeader: true
        });
    });

</script>