我有一个带有增强表的数据表。我需要获取数据表中的总行数,而不是特定页面中的行数。请帮帮我。
这是工作代码的小提琴:https : //jsfiddle.net/6w8nbhr1/ 计数为 10,但在小提琴中显示为 42。在这种情况下,如何准确获取行数为 10。请按照小提琴处理数据
$(document).ready(function() {
$('#example').dataTable();
});
Run Code Online (Sandbox Code Playgroud)
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$86,000</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td> …
Run Code Online (Sandbox Code Playgroud)有没有办法pageLength
在jQuery的"window.resize"事件中更改运行时dataTable 的设置?
这些是我正在使用的dataTable设置
$('#dataTable').DataTable({
paging: true,
pageLength: 35,
searching: true,
lengthChange: false,
info: false,
scrollCollapse: true,
scrollY: "calc(74vh)"
});
Run Code Online (Sandbox Code Playgroud)
pageLength
每当窗口调整大小时,我希望更改.
我正在尝试这个
$(window).resize(function () {
if ($(this).height() >= "1080"){
// change the dataTable pageLength in here
$('#dataTable').DataTable({ pageLength: 50 });
} else {
// default pageLength
$('#dataTable').DataTable({ pageLength: 35 });
}
});
Run Code Online (Sandbox Code Playgroud) 我正在使用jQuery DataTables,但在我的JSON子对象遇到问题时null
.我的JSON有一个嵌套对象,因此address
可以在下面返回错误/警告.null
address.streetAddress1
DataTables警告:table id = directory-table - 第0行请求的未知参数'address.streetAddress1'.有关此错误的更多信息,请参阅http://datatables.net/tn/4
有没有办法处理null
值,所以它只是一个空白字符串?
$(document).ready(function() {
$('#directory-table').dataTable( {
"lengthMenu": [ 10, 25, 50, 100 ],
"dom": 'C<"clear">lfrtip',
"ajax": {
"url": "directory.json",
"dataSrc" : ""
},
scrollX:true,
"columns": [
{"data" : "fileId"},
{"data" : "fileName"},
{"data" : "institutionId"},
{"data" : "id"},
{"data" : "firstName"},
{"data" : "middleName"},
{"data" : "lastName"},
{"data" : "prefix"},
{"data" : "suffix"},
{"data" : "preferredName"},
{"data" : "gender"},
{"data" : "deleteFlag"},
{"data" : …
Run Code Online (Sandbox Code Playgroud) 我想在加/减绿色/红色按钮中添加工具提示,请参阅 此示例。我怎样才能做到这一点?
我正在使用jQuery DataTables 1.10,我的所有代码都运行正常.要添加导出功能,请参阅此链接.我已经添加了所说的所有文件
//code.jquery.com/jquery-1.11.3.min.js
https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js
https://cdn.datatables.net/buttons/1.0.3/js/dataTables.buttons.min.js
//cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js
//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js
//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js
//cdn.datatables.net/buttons/1.0.3/js/buttons.html5.min.js
//cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css
//cdn.datatables.net/buttons/1.0.3/css/buttons.dataTables.min.css
Run Code Online (Sandbox Code Playgroud)
我已下载这些文件并存储在本地.所以我的最终代码如下:
table = $(".jqueryDataTable").DataTable( {
"initComplete": function(oSettings, json) {
alert( 'DataTables has finished its initialisation in table.' );
this.fnHideEmptyColumns(this);
$('#lblReportHeader').html(reportHeader);
$('#lblFromDate').html(fromDateHeader);
$('#lblToDate').html(fromToHeader);
$('#tblReportHeader').show();
},
"searching": false,
"retrieve": true,
"destroy": true,
"ajax": "./getReportDetails",
"jQueryUI": true,
"dom": 'r<"H"lf><"datatable-scroll"t><"F"ip>',
buttons: [
'copyHtml5',
'excelHtml5',
'csvHtml5',
'pdfHtml5'
],
"fnServerParams": function ( data ) {
newData=data;
newData.push( { "name": "reportType", "value": reportType }, { "name": "reportSubType", "value": reportSubType}, { "name": "fromDate", "value": …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将json数据(从Web API ajax调用中检索)加载到jQuery DataTables,但是我收到以下错误:
https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js第38行第38行未处理的异常
0x800a138f - JavaScript运行时错误:无法获取未定义或空引用的属性"长度"
这是我的jQuery调用:
$(document).ready(function () {
$('#stat').DataTable({
"responsive": true,
"paging": false,
"ordering": false,
"info": false,
"bFilter": false,
"processing": true,
"serverSide": true,
"ajax": {
'url': 'http://localhost:61178/api/financeStats'
}
});
});
Run Code Online (Sandbox Code Playgroud)
这是我从Web API调用中检索到的JSON数据:
[
{
"Description": "Total Sas debt at yesterday",
"TotAgents": 788,
"TotAmount": 1767595.5854
},
{
"Description": "Total CL Sas with Rid worked yesterday",
"TotAgents": 413,
"TotAmount": 3026100
},
{
"Description": "Total CL Sas with No Rid worked yesterday",
"TotAgents": 164,
"TotAmount": 1252650
},
{ …
Run Code Online (Sandbox Code Playgroud) 我正在使用jQuery DataTables,并正在寻找一种如何从JSON完全生成DataTable的方法。这应该包括列数,它们的名称,行数据,但还可以包括其他设置(例如排序)。我已经看到这是可能的,但是在许多可能的方法中,对我来说工作并不多。
这是我的代码,您能帮我解决错误并详细说明当前的JSON配置吗?
JSON-尽可能放在此处:
{
"columns": [
[ "title" : "DT_RowId" ],
[ "title" : "supplier" ],
[ "title" : "color" ],
],
"data": [
[ "row_3", "small", "red" ],
[ "row_3", "medium", "blue" ],
[ "row_3", "medium", "blue" ],
[ "row_11", "large", "blue" ],
]
}
Run Code Online (Sandbox Code Playgroud)
JS:
$('#example').DataTable( {
"ajax" : {
"url": "http://127.0.0.1/tabledata.json",
"type": "GET",
"contentType" : "application/json",
"dataType" : "jsonp",
},
});
Run Code Online (Sandbox Code Playgroud)
HTML-应该保留为最少:
<table id="example"></table>
Run Code Online (Sandbox Code Playgroud)
当前错误:
TypeError:未定义不是对象(评估'e [i] .aDataSort')
jquery json datatables jquery-datatables-editor datatables-1.10
我想启用排序但同时将多个行组合为一个。这样他们将始终按组排序。像第 1 组的行将坚持第 1 组等..
我花了太多时间,无法理解为什么数据表无法刷新我的表,我已经对这个数据表感到疯狂
我的代码在下面,我花了数周的时间但无法正常工作,我使用了ajax.reload
DataTablesDraw = (selector, order, pages, file, sort, column, template, data_set) ->
$(selector).DataTable
'pageLength': pages
'ordering': sort
'destroy' : true,
'paging': true
'responsive': true
'searching': false
'info': false
'lengthChange': true
'autoWidth': false
'select': true
'dom': 'Bfrtip',
'buttons': [
{
'extend': 'excelHtml5',
'title': file + new Date()
},
'copyHtml5'
],
'order': [ [ column, 'desc' ] ],
'language': {
buttons: {
copyTitle: i18n[lang]['id[9]'],
copySuccess: {
_: i18n[lang]['id[10]'] + ' %d ' + i18n[lang]['id[11]'],
1: i18n[lang]['id[12]']
}
}
}
'ajax': '/settings/ranges/ranges.txt', …
Run Code Online (Sandbox Code Playgroud) datatables ×10
javascript ×8
jquery ×8
json ×3
ajax ×2
html ×2
css ×1
datatable ×1
sorting ×1
tooltip ×1