无法读取 Salesforce 中未定义的 属性 'mData'
Cannot read property 'mData' of undefined in Salesforce
我正在尝试从列表中获取数据并使用 jQuery 对其进行排序,但为此我在控制台上收到此错误。
Cannot read property 'mData' of undefined on Console.
如果我添加静态数据,它就可以正常工作。我是 jQuery.
的新手
VF 页面
<apex:page sidebar="false" controller="PaginationCon">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
<link href="https://cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css" rel="stylesheet"/>
<script type="text/javascript">
$(function () {
$("#example1").dataTable();
});
</script>
<apex:form >
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Name</th>
<th>BodyLength</th>
<th>Created Date</th>
<th>Owner Name</th>
<th>Click To View</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!att}" var="at">
<tr>
<td> <apex:outputText value="{!at.Name}"/></td>
<td> <apex:outputText value="{!at.BodyLength}"/></td>
<td> <apex:outputText value="{!at.CreatedDate}"/></td>
<td> <apex:outputText value="{!at.Owner.Name}"/></td>
<td> <apex:commandLink value="View"/></td>
<td> <apex:commandLink value="Delete"/></td>
</tr>
</apex:repeat>
</tbody>
</table>
</apex:form>
</apex:page>
控制器
public with sharing class PaginationCon {
public List<Attachment> att{get;set;}
public PaginationCon ()
{
att=new List<Attachment>();
att=[select id,Name,BodyLength,CreatedDate,Owner.Name from Attachment limit 1000];
}
}
只需在下面添加此元素 "Click to View" Table Header
<th>Click To Delete</th>
现在应该是这样了
<thead>
<tr>
<th>Name</th>
<th>BodyLength</th>
<th>Created Date</th>
<th>Owner Name</th>
<th>Click To View</th>
<th>Click To Delete</th>
</tr>
</thead>
<thead>
和 <tbody>
应具有相同的列数。
我正在尝试从列表中获取数据并使用 jQuery 对其进行排序,但为此我在控制台上收到此错误。
Cannot read property 'mData' of undefined on Console.
如果我添加静态数据,它就可以正常工作。我是 jQuery.
的新手VF 页面
<apex:page sidebar="false" controller="PaginationCon">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
<link href="https://cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css" rel="stylesheet"/>
<script type="text/javascript">
$(function () {
$("#example1").dataTable();
});
</script>
<apex:form >
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Name</th>
<th>BodyLength</th>
<th>Created Date</th>
<th>Owner Name</th>
<th>Click To View</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!att}" var="at">
<tr>
<td> <apex:outputText value="{!at.Name}"/></td>
<td> <apex:outputText value="{!at.BodyLength}"/></td>
<td> <apex:outputText value="{!at.CreatedDate}"/></td>
<td> <apex:outputText value="{!at.Owner.Name}"/></td>
<td> <apex:commandLink value="View"/></td>
<td> <apex:commandLink value="Delete"/></td>
</tr>
</apex:repeat>
</tbody>
</table>
</apex:form>
</apex:page>
控制器
public with sharing class PaginationCon {
public List<Attachment> att{get;set;}
public PaginationCon ()
{
att=new List<Attachment>();
att=[select id,Name,BodyLength,CreatedDate,Owner.Name from Attachment limit 1000];
}
}
只需在下面添加此元素 "Click to View" Table Header
<th>Click To Delete</th>
现在应该是这样了
<thead>
<tr>
<th>Name</th>
<th>BodyLength</th>
<th>Created Date</th>
<th>Owner Name</th>
<th>Click To View</th>
<th>Click To Delete</th>
</tr>
</thead>
<thead>
和 <tbody>
应具有相同的列数。