gpt4 book ai didi

c# - 0x800a138f - JavaScript 运行时错误 : Unable to get property 'mData' of undefined or null reference

转载 作者:行者123 更新时间:2023-11-30 13:45:24 25 4
gpt4 key购买 nike

我使用的是 Datatables 版本 1.10.6。在 jquery.dataTables.js 中,我遇到了上述错误。

0x800a138f - JavaScript 运行时错误:无法获取未定义或空引用的属性“mData”。

$.each( _fnGetRowElements( oSettings, rowOne[0] ).cells, function (i, cell) {
var col = oSettings.aoColumns[i];

if ( col.mData === i ) {// this line gives error
var sort = a( cell, 'sort' ) || a( cell, 'order' );
var filter = a( cell, 'filter' ) || a( cell, 'search' );

if ( sort !== null || filter !== null ) {
col.mData = {
_: i+'.display',
sort: sort !== null ? i+'.@data-'+sort : undefined,
type: sort !== null ? i+'.@data-'+sort : undefined,
filter: filter !== null ? i+'.@data-'+filter : undefined
};

_fnColumnOptions( oSettings, i );
}
}
} );
}

我在 MVC 中使用:

<script type="text/javascript">
$(document).ready(function () {
// Setup - add a text input to each footer cell

$('#example tfoot th').each(function () {
var title = $('#example thead th').eq($(this).index()).text();
$(this).html('<input type="text" placeholder="Search ' + title + '" />');

});



// DataTable

var table = $('#example').DataTable();
alert(table);

// Apply the search

table.columns().every(function () {
var that = this;
$('input', this.footer()).on('keyup change', function () {
that
.search(this.value)
.draw();

});

});

});
</script>

<table class="display" id="example" cellspacing="0">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Employee Id</th>
<th>Active</th>
<th>SFDC</th>
<th>System User</th>
</tr>
</thead>

<tfoot>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Employee Id</th>
<th>Active</th>
<th>SFDC</th>
<th>System User</th>
</tr>

</tfoot>

<tbody>

@foreach (var item in Model)
{
<tr>
<td valign="middle" align="center">
@Html.DisplayFor(modelitem => item.FirstName)
</td>
<td valign="middle" align="center">
@Html.DisplayFor(modelitem => item.LastName)
</td>

<td valign="middle" align="center">
@Html.DisplayFor(modelitem => item.EmailAddress)
</td>
<td valign="middle" align="center">
@Html.DisplayFor(modelitem => item.EmployeeId)
</td>
<td valign="middle" align="center">
@Html.DisplayFor(modelitem => item.IsActive, true)
</td>
<td valign="middle" align="center">
@Html.DisplayFor(modelitem => item.IsSFDC, true)
</td>
<td valign="middle" align="center">
@Html.DisplayFor(modelitem => item.IsSystemUser, true)
</td>
<td valign="middle" align="center">
@Html.ActionLink(" ", "Edit", new { id = item.UserId }, new { @class = "edit_btn", title = "Edit" })
@Html.ActionLink(" ", "Details", new { id = item.UserId }, new { @class = "details", title = "Details" })
@Html.ActionLink(" ", "Delete", new { id = item.UserId }, new { @class = "delete", title = "Delete" })
</td>
</tr>
}

</tbody>
</table>

最佳答案

标题列的数量不匹配导致了这个问题,标题列和行列的数量应该相等。

关于c# - 0x800a138f - JavaScript 运行时错误 : Unable to get property 'mData' of undefined or null reference,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29918137/

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