datatables 使用排序后显示‘No data available in table’

我在使用datatables时,可以正常的显示页面,但是只要使用了排序或者是调整一页可以显示的个数,原本表格里的数据就没了,只显示No data available in table。就像https://jsfiddle.net/z4zk9zdz/1/这种一样。

3个回答

sinat_24601593
魏宇辰 好尴尬,用了他讲的方法,但是没有效果
接近 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
前端datatables排序问题

我自定义的排序有点问题,顺序不对,大神帮忙看看呗,是我return里面写错了么

JQuery DataTables默认排序无效

<div class="post-text" itemprop="text"> <p>My datatable default sorting is not working for some reason that I haven't been able to figure out. The data is displayed correctly though. Pagination is not working either. The first column contains images, but I'm setting it for default to not execute any sort.</p> <p>Any help is really appreciated.</p> <p>Here's part of the code I'm using:</p> <pre><code>var oTable = $('#datatables').dataTable( { "aaSorting": [[2, 'asc']], "bProcessing": true, "bServerSide": true, "sPaginationType": "full_numbers", "sAjaxSource": "process.php", "aoColumns": [ { "mData": null, "aTargets": [0], "bSerchable": false, "bSortable": false, "sDefaultContent": '&lt;div class="expand /"&gt;', "sWidth": "30px" }, { "mDataProp": "email", "aTargets": [1], "bSearchable": true, "bSortable": true }, { "mDataProp": "lastName", "aTargets": [2], "bSearchable": true, "bSortable": true }, { "mDataProp": "firstName", "aTargets": [3], "bSearchable": true, "bSortable": true }, { "mDataProp": "dateRegistered", "aTargets": [4], "sClass": "center", "bSearchable": true, "bSortable": true } ] } ); </code></pre> <p>I just added the "aTargets", works the same with our without them.</p> <p>Here's the file that returns the json array:</p> <pre><code>&lt;?php try { $conn = require_once 'dbConnect.php'; $sql = "SELECT email, lastName, firstName, dateRegistered, state FROM Users"; $result = $conn-&gt;prepare($sql) or die ($sql); if(!$result-&gt;execute()) return false; if($result-&gt;rowCount() &gt; 0) { $json = array(); while($row = $result-&gt;fetch()){ $json[] = array( 'email' =&gt; $row['email'], 'lastName' =&gt; $row['lastName'], 'firstName' =&gt; $row['firstName'], 'dateRegistered' =&gt; $row['dateRegistered'], 'state' =&gt; $row['state'] ); } $response = array( "iTotalRecords" =&gt; strval(count($json)), "iTotalDisplayRecords" =&gt; strval(count($json)), "aaData" =&gt; $json ); echo json_encode($response); } } catch(PDOException $e) { echo 'Error: ' . $e-&gt;getMessage(); } ?&gt; </code></pre> <p>Thanks.</p> </div>

datatables分页怎么对当前页排序

在使用datatables分页时,点击排序怎么能只对当前页排序。而不是所有的数据排序

关于datatables 禁止排序 导致 无法获取行号

给datatables 加上了"bSort": false 或者'ordering':false 然后序号就获取不到了,该如何解决呢

Jquery DataTables可排序距离列

<div class="post-text" itemprop="text"> <p>SO I have jQuery DataTables setup and running fine. My eventual goal, is to allow the user to use google places autocomplete, to update their location, and then to have a 'sortable' distance column added to my DataTables table, upon refresh.</p> <p>The plan is is to have a button next to the text input of google autocomplete, that says use this address, once user searches for and finds an address using autocomplete, and then pushes the button , I want to (probably)send them to a loading page for a few seconds whilst we</p> <p>1)read the text string, format it for use with google geo coding api, aka</p> <p>"Cranbourne, Victoria, Australia" ----&gt; "Cranbourne+Victoria+Australia"</p> <p>2)insert it in a geocode request</p> <p>3)extract the lat and lon values from the resulting json, and assign them to vars</p> <p>Now comes the hard part, I was thinking using some php, to calculate the distance between the users(lat,long), and every entry that was in the DataTable table, which was was populated with sql data using a foreign key (all sql rows have lat lon data) </p> <p>Then I was thinking of sending said entries to an xml, only this time every entry will have an extra value "DISTANCE".</p> <p>Of coarse with some clever code this whole thing wont take a second, the new DataTable table is then populated with the xml, only this time it contains a distance column with distance values for every row, which of coarse will be sortable, without any DataTables hacks what so ever.</p> <p>So am I stupid, or is this somewhat of a good idea, is there an easier way?</p> <p>I would really like some answers to this thank you.</p> </div>

jQuery DataTables - 单击列时排序不起作用

<div class="post-text" itemprop="text"> <p>The tabs/search bar/page entries appear at the top of the table as expected. But they are not sorted when clicked. It's like it only looks at the first row.</p> <pre><code>&lt;script&gt; $(document).ready( function () { $('#aeotable').DataTable(); } ); &lt;/script&gt; echo ' &lt;table id="aeotable" class="display"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Company Name&lt;/th&gt; &lt;th&gt;Expiry insurance certificate&lt;/th&gt; &lt;th&gt;Comments&lt;/th&gt; &lt;th&gt;File Name&lt;/th&gt; &lt;th&gt;&amp;nbsp;&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt;'; // Print each file while($row = $result-&gt;fetch_assoc()) { echo " &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;{$row['cop']}&lt;/td&gt; &lt;td&gt;{$row['expo']}&lt;/td&gt; &lt;td&gt;{$row['dec']}&lt;/td&gt; &lt;td&gt;{$row['fil']}&lt;/td&gt; &lt;td&gt;&lt;a download href=\"file/{$row['file']}\"&gt;Download&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;"; } // Close tabl echo '&lt;/table&gt;'; </code></pre> </div>

PHP / Datatables:数字按文本排序

<div class="post-text" itemprop="text"> <p>I am using Datatables to style a table that I fill with PHP. </p> <p>Everything works as intended except for a column containing amounts. If I click on the Datatables column header for this column in order to sort the table by this column it sorts it but only as text instead of numbers so that 20 appears before 3 etc. </p> <p>Is there a way I can prevent this in PHP by changing the format ?</p> <p><strong>Example cell:</strong> </p> <pre><code>&lt;td class="colAmount ralign"&gt;&lt;?php echo number_format(doubleval($requests-&gt;amount), 2, ".", ","); ?&gt;&lt;/td&gt; </code></pre> <p>If an amount in my database ($requests-&gt;amount) is e.g. 100000 then the above would format this as 100,000.00 as I need to display it with the thousands and decimal separators - this is then probably interpreted as text. </p> <p>Many thanks in advance, Tim. </p> </div>

jQuery dataTables使用的时候,返回json数据填充,不能进行分页,而是显示全部数据

今天遇到这样的问题,就是利用jQuery dataTables表格插件,将我后台返回来的JSON数据填充,但是不能分页,而是显示全部的数据,很奇怪,这是运行的截图和jQuery dataTables参数的设置,大牛们帮忙看看,小弟也是刚接触jQuery dataTables。 [code="java"] function loadCustomerInfo(){ var datatable; if(datatable == undefined || datatable == "undefined" || datatable == null){ $("#exportTable").show(); datatable=$("#exportTable").dataTable({ "sPaginationType": "full_numbers", "bFilter":false, "bSort":false, "iDisplayLength": 5, "bRetrieve":true, "bPaginate":true, "bLengthChange": false, "bStateSave" :false, "bServerSide": true, "aoColumns": [ {"mDataProp":"customerID"}, {"mDataProp":"customerName"}, {"mDataProp":"customerTel"}, {"mDataProp":"salesDate"}, {"mDataProp":"operate", "mRender": function(data, type, full) { return '<A href="../OrderdetailsServlet?customerID='+data+'" target="_blank">订单详情</A>';} }], "oLanguage":{ "sLengthMenu": "每页显示 _MENU_ 条记录", "sZeroRecords": "没有检索到数据", "sInfo": "显示 _START_-_END_ 条数据;共有 _TOTAL_ 条记录", "sInfoEmtpy": "没有数据", "sProcessing": "正在加载数据...", "oPaginate": { "sFirst": "首页", "sPrevious": "上一页", "sNext": "下一页", "sLast": "尾页" } }, "sAjaxSource" : "../CustomerServlet?rand="+Math.random(), "fnServerData" : function(sSource, aoData, fnCallback){ $.getJSON( sSource, {contractID:$("#contractID").val(), customerName:encodeURI(encodeURI($("#customerName").val())), customerTel:$("#customerTel").val(), aoData:JSON.stringify(aoData)} , function callback(data){ fnCallback(data); }); } }); } else{ datatable.fnDestroy(); } datatable.fnDraw(); } [/code] [img] [/img]

如何使用DataTables使两行显示为一行?

<div class="post-text" itemprop="text"> <p>I have a page with a listing of groups here:</p> <p><a href="http://liquidchurch.com/groups/groups-browse/" rel="nofollow">http://liquidchurch.com/groups/groups-browse/</a></p> <p>It is using WordPress, DataTables, and the CCB Core API plugin and works well.</p> <p>I need to add to each group a description, but the descriptions are too long to add to the end of the table, so I'd like for it to appear on a separate line but still be "attached" to the main row (about the group) both in visual appearance and for sorting purposes.</p> <p>Here is my current code:</p> <p><a href="https://gist.github.com/davidshq/2c54fae1d3fd73bc6eda7dc537c1abed" rel="nofollow">https://gist.github.com/davidshq/2c54fae1d3fd73bc6eda7dc537c1abed</a></p> </div>

请教 Datatables 分页无法显示所有页码,点击下一页无效果。

自己尝试使用Datatables来做页面渲染,但遇到无法显示全部分页页码,点击分页按钮也无响应,如下图: ![图片说明](https://img-ask.csdn.net/upload/201810/20/1540026695_297890.png) 服务端返回的数据共6条,页面大小是2,按道理应该显示1,2,3三个页码,但目前只能显示第一页,服务端返回的数据如下: ``` { "data": [ { }, { } ], "draw": 2, "recordsTotal": 6, "recordsFiltered": 2, "error": null } ``` 请大神帮忙看下,我这个Datatables 分页怎么不好使的,感谢!

datatables.net列对另一列进行排序

<div class="post-text" itemprop="text"> <p>I'm still in deep trouble with that issue. I use datatable.net to display some data from my database (mySql).</p> <p>I do exactely what the API notice me to do in order to sort columns by name ASC (toggle DESC). <a href="https://datatables.net/manual/server-side" rel="nofollow noreferrer">https://datatables.net/manual/server-side</a></p> <blockquote> <p>order[i][column] integer Column to which ordering should be applied. This is an index reference to the columns array of information that is also submitted to the server. </p> <p>order[i][dir] string Ordering direction for this column. It will be asc or desc to indicate ascending ordering or descending ordering, respectively.</p> </blockquote> <p>So my code is like this:</p> <p>AJAX call:</p> <pre><code>var dataTable = $('#tableau').DataTable({ "processing":true, "serverSide":true, "order":[], "orderFixed": [], "ordering":true, "ajax":{ url:"/charbon/clae-listes/actions/appel.php", type:"POST" }, "columnDefs":[ { "targets":[ 2, 3], "orderable":false, }, ], }); </code></pre> <p>And my appel.php script</p> <pre><code>... if(isset($_POST["order"])) { $query .= 'ORDER BY '.$_POST['order'][0]['column'].' '.$_POST['order'][0]['dir'].' '; } else { $query .= 'ORDER BY id DESC '; } ... </code></pre> <p>That's where trouble begins: </p> <p>when I click my 1st column I receive that error message on localhost :</p> <blockquote> <p>DataTables warning: table id=tableau - Invalid JSON response. For more information about this error, please see <a href="http://datatables.net/tn/1" rel="nofollow noreferrer">http://datatables.net/tn/1</a></p> </blockquote> <p>And when I click my 2nd column to sort it that sorts the previous column. It's like datatables picks directly the column number from my database, and offset of 1 because my database doesn't have a column 0</p> <p>how to attribute the right column to the right sorting?</p> <p>output JSON response</p> <p>1st column</p> <pre><code>&lt;b&gt;Fatal error&lt;/b&gt;: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'order clause' in /Users/.../appel.php:45 </code></pre> <p>2nd column</p> <pre><code>{"draw":9,"recordsTotal":10,"recordsFiltered":11,"data":[["type","Client","client"......... </code></pre> <p>My headers</p> <pre><code>draw:9 columns[0][data]:0 columns[0][name]: columns[0][searchable]:true columns[0][orderable]:true columns[0][search][value]: columns[0][search][regex]:false columns[1][data]:1 columns[1][name]: columns[1][searchable]:true columns[1][orderable]:true columns[1][search][value]: columns[1][search][regex]:false columns[2][data]:2 columns[2][name]: columns[2][searchable]:true columns[2][orderable]:true columns[2][search][value]: columns[2][search][regex]:false columns[3][data]:3 columns[3][name]: columns[3][searchable]:true columns[3][orderable]:false columns[3][search][value]: columns[3][search][regex]:false order[0][column]:1 order[0][dir]:asc start:0 length:10 search[value]: search[regex]:false </code></pre> </div>

显示JSON数据但未绘制表格(使用Datatables - 服务器端处理)

<div class="post-text" itemprop="text"> <p>I am using Yajra's DataTables server side processing. I can see the JSON data but the table is not being populated.</p> <p>I managed to get DataTables working with client side processing, but as I will eventually have &gt; 50,000 rows of data, I decided to try and implement server side processing by downloading Yajra's DataTables for Laravel 5.8.</p> <p>When I call my route, I see the data in a JSON format, but I am not seeing the table at all. It says "draw: 0", so I guess there is an issue with drawing the table?</p> <p>I have tried various solutions mentioned on stack overflow and the official DataTables website, however none seem to work for me. E.g.<br> - <a href="https://stackoverflow.com/questions/55647900/datatables-json-is-not-processed-in-laravel">DataTables json is not processed (in Laravel)</a><br> - <a href="https://stackoverflow.com/questions/14829530/jquery-datatables-table-not-populated-for-ajax-response">jQuery Datatables - Table not populated for Ajax response</a><br> - <a href="https://datatables.net/forums/discussion/45444/populate-table-body-with-ajax" rel="nofollow noreferrer">https://datatables.net/forums/discussion/45444/populate-table-body-with-ajax</a> </p> <p>The JSON data that I see when I call my route is as follows:</p> <pre><code> { "draw": 0, "recordsTotal": 3, "recordsFiltered": 3, "data": [ { "id": "1", "customerNr": "98764", "orderNr": "23478", "pallet_id": "66788", "status_id": "2", "created_by": "Sara", "created_at": "04 Jul 2019", "updated_at": "2019-07-09 07:23:20" }, { "id": "2", "customerNr": "99999", "orderNr": "22222", "pallet_id": "22335", "status_id": "1", "created_by": "Sophie", "created_at": "04 Jul 2019", "updated_at": "2019-07-04 08:26:28" }, { "id": "3", "customerNr": "54657", "orderNr": "89856", "pallet_id": "11228", "status_id": "1", "created_by": "Markus", "created_at": "08 Jul 2019", "updated_at": "2019-07-08 06:59:42" }, ], "input": [] } </code></pre> <p>Here are the relevant files from my Laravel project:</p> <p>web.php:</p> <pre><code>Route::get('returned-shipment', ['uses'=&gt;'ReturnedShipmentController@index', 'as'=&gt;'returned-shipment.index']); </code></pre> <p>ReturnedShipmentController:</p> <pre><code>public function index( { return DataTables::of(ReturnedShipment::all())-&gt;make(); } </code></pre> <p>index.blade.php:</p> <pre><code>&lt;div class="row"&gt; &lt;div id="tbl" class="col-sm-12"&gt; &lt;table id="overview" class="cell-border display"&gt; &lt;thead class="tbl-top"&gt; &lt;tr&gt; &lt;th&gt;Retourennummer&lt;/th&gt; &lt;th&gt;Auftragsnummer&lt;/th&gt; &lt;th&gt;Datum&lt;/th&gt; &lt;th&gt;Zustand&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tfoot class="tbl-bottom"&gt; &lt;tr&gt; &lt;th&gt;Retourennummer&lt;/th&gt; &lt;th&gt;Auftragsnummer&lt;/th&gt; &lt;th&gt;Datum&lt;/th&gt; &lt;th&gt;Zustand&lt;/th&gt; &lt;/tr&gt; &lt;/tfoot&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt; &lt;script&gt; $(document).ready(function () { var startingStatus = 'angelegt'; var table = $('#overview').DataTable({ "processing": true, "serverSide": true, "ajax": "{{ route('returned-shipment.index') }}", "columns": [ {data: 'id'}, {data: 'orderNr'}, {data: 'created_at'}, {data: 'status_id'} ], "search": { "search": "angelegt" }, "dom": "&lt;'row'&lt;'col-sm-4'l&gt;&lt;'col-sm-8'f&gt;&gt;" + "&lt;'row'&lt;'col-sm-12'tr&gt;&gt;" + "&lt;'row'&lt;'col-sm-6'i&gt;&lt;'col-sm-6'p&gt;&gt;", "paging": true, "info": true, "searching": true, "autoWidth": true, "language": { "paginate": { "previous": "Vorherige Seite", "next": "Nächste Seite" }, "search": "Suche:", "info": "Zeige _START_ - _END_ von insgesamt _TOTAL_ Einträgen", "lengthMenu": 'Einträge pro Seite' + '&lt;br&gt;' + '&lt;select class="custom-select mr-sm-2" id="inlineFormCustomSelect"&gt;' + '&lt;option selected value="10"&gt;10&lt;/option&gt;' + '&lt;option value="20"&gt;20&lt;/option&gt;' + '&lt;option value="30"&gt;30&lt;/option&gt;' + '&lt;option value="40"&gt;40&lt;/option&gt;' + '&lt;option value="50"&gt;50&lt;/option&gt;' + '&lt;option value="-1"&gt;Alle&lt;/option&gt;' + '&lt;/select&gt;' }, initComplete: function () { /** * Drop-down filter is created for the 4th column "status" in the header and populates it with * the different status values */ this.api().columns([3]).every(function () { var column = this; var select = $('&lt;select&gt;&lt;option value=""&gt;alle&lt;/option&gt;&lt;/select&gt;') .appendTo($(column.header())) .on('change', function () { var val = $.fn.dataTable.util.escapeRegex( $(this).val() ); column .search(val ? '^' + val + '$' : '', true, false) .draw(); }); /** * When clicking on drop-down next to status, the sorting function is not activated */ $(select).click(function (e) { e.stopPropagation(); }); /** * Once an option in the drop-down next to status has been selected, you can read the text in * the drop-down */ column.data().unique().sort().each(function (d, j) { if (startingStatus === d) { select.append('&lt;option SELECTED value="' + d + '"&gt;' + d + '&lt;/option&gt;') } else { select.append('&lt;option value="' + d + '"&gt;' + d + '&lt;/option&gt;') } }); /** * When drop-down is clicked on, search field is cleared. Otherwise search field must be * manually cleared before using the drop-down. */ $(select).on('click', function () { table.search(" ").draw(); }); }); } }); }); &lt;/script&gt; </code></pre> <p>I am expecting to see the table being populated with the data.</p> <p>If I need to provide any more code or explain something further, please don't hesitate to ask. I am quite new to Laravel and DataTables, so I would greatly appreciate your help.</p> <p>Thanks in advance! :)</p> </div>

bootstrap datatables加载不出数据

``` $(document).ready(function () { var tables = $('#notice_table').DataTable({ "oLanguage": { //表格的语言设置 "sProcessing": "正在获取数据,请稍后...", "sLengthMenu": "显示 _MENU_ 条", "sZeroRecords": "没有您要搜索的内容", "sInfo": "从 _START_ 到 _END_ 条记录 总记录数为 _TOTAL_ 条", "sInfoEmpty": "记录数为0", "sInfoFiltered": "(全部记录数 _MAX_ 条)", "sInfoPostFix": "", "sSearch": "搜索", "sUrl": "", "oPaginate": { "sFirst": "第一页", "sPrevious": "上一页", "sNext": "下一页", "sLast": "最后一页" }, "bProcessing": true, //DataTables载入数据时显示‘进度’提示 // "serverSide": true, "autoWidth": false, //"sScrollY" : 350, //DataTables的高 "sPaginationType": "full_numbers", //详细分页组,可以支持直接跳转到某页 "iDisplayStart": 0,//刷新插件后显示的第几页(如果一页为10条数据,填10就显示第二页) "ajax": { "url": "/publish/json.do?publishTypeId=" + publishTypeId }, "columns": [//定义接受到的数据 { "data": "publishPerson" } ], 'bStateSave': true,//刷新页面让页面停留在之前的页码 "columnDefs": [{ "targets": 6,//编辑 "data": null,//添加编辑按钮和,删除按钮 "defaultContent": "<button id='editrow' class='btn btn-primary' type='button' style='margin-right:10px;'>编辑</button><button id='delrow' class='btn btn-primary' type='button'>删除</button>" }], "createdRow": function (row, data, index) { //每加载完一行的回调函数 $('td', row).eq(5).css('font-weight', "bold").css("color", "red");//获取到具体行具体格的元素 } } }) ``` json:![图片说明](https://img-ask.csdn.net/upload/201610/20/1476961850_893527.png) 加载不出数据,可加分

DataTables警告:无法解析来自服务器的JSON数据。 这是由JSON格式错误引起的

<div class="post-text" itemprop="text"> <p>I am using server-side DataTables in a project</p> <p>and do a search, shows me the following error message:</p> <p><code>DataTables warning: JSON data from server not could be parsed. This is Caused by a JSON formatting error.</code></p> <p>I found some suggestions in the forums but nothing has worked for me</p> <p>Anyone have any suggestions?</p> </div>

如何对包含jQuery Datatables中数据库值以外的服务器端生成值的列进行排序。

<div class="post-text" itemprop="text"> <p>I am using <code>jQuery Datatables</code> for one of my page to display data.I am using <code>server-side scripting</code> to display datatables.</p> <p>In my html I have <strong>8 columns</strong>.5 columns for fetched values and other 3 contains <code>some mathematics calculations with php functions</code> that I am returning in the server side script.Those are not depends on database fields.</p> <p>I changed $output[] to add my generated values and all are work fine.</p> <p>What my problem is I need to <code>sort columns that have generated values</code>.But this is not possible because datatables mysql ordering statement makes error because these columns are not in actual mysql table.</p> <p>So how would I able to do sorting above fields? Do we have any sorting that I can do for those columns without interfering mysql ordering clause(may be sort in client side).</p> <p>Thanks.</p> </div>

datatables.min.js的使用

使用datatables.min.js对table进行分页处理, 5条一页, 首次登陆界面后台查询9条数据到前台正常显示分为2页, 后修改select控件, 再次调用后台查询到7条数据到前台, 前台报错, 如下图, 而且通过上一页下一页还是可以查询到9条数据, 这是怎么回事, 调试时也检查了后台传递过来的值是7条的.请各位大神帮忙看看, 是不是还有什么属性没有设置, 谢谢! ![图片说明](https://img-ask.csdn.net/upload/201703/15/1489563612_525968.png) ``` function GetList() { var UserName = $("#txt_keyword").val(); var selectId = $("#AccountSelect").val(); $.ajax({ type: "POST", url: "/Backstage/SystemManage/GetUserForAjax", data: { UserName: UserName, selectId: selectId }, success: function (result) { html = ""; $("#tbodyDept").html(html); if (result.State == 0 && result.Data.length > 0) { for (var i = 0; i < result.Data.length; i++) { html += "<tr>"; html += "<td><input type=\"checkbox\" value=\"" + result.Data[i].Id + "\" class=\"i-checks\" name=\"input[]\"></td>"; html += "<td><small>" + result.Data[i].Account + "</small></td>"; html += "<td><small>" + result.Data[i].RealName + " </small></td>"; html += "</tr>"; } } $("#tbodyDept").html(html); $('.table').DataTable({ "iDisplayLength": 5, "bFilter": false, //过滤功能 "bSort": false, //排序功能 "bLengthChange": false, //改变每页显示数据数量 "oLanguage": { "sZeroRecords": "没有找到符合条件的数据", "sProcessing": "<img src=’./Content/InspiniaAdmin/css/plugins/blueimp/img/loading.gif’ />", "sInfo": "当前第 _START_ - _END_ 条 共计 _TOTAL_ 条", "sInfoEmpty": "没有记录", "oPaginate": { "sFirst": "首页", "sPrevious": "前一页", "sNext": "后一页", "sLast": "尾页" } } }); }, error: function () { $("#tbodyDept").html("<tr><td colspan=\"10\"><small class=\"text-warning\">查询数据出现错误!</small></td></tr>"); } }); } ``` 可能描述的不太清楚, 实现过程就是通过select控件选择重新查询数据.

使用PHP ECHO填充时,DataTables子行无法正确显示

<div class="post-text" itemprop="text"> <p>I have looked at all the examples I can find but haven't found an answer to this.</p> <p>I have a DataTables table which is loaded by PHP echos, after manipulating data from MySQL queries.</p> <p>I now want to add child rows showing extra data, basically the same format type as the DataTables examples (<a href="http://datatables.net/examples/api/row_details.html" rel="nofollow noreferrer">http://datatables.net/examples/api/row_details.html</a>) </p> <p>I have modified the table by adding an extra <code>&lt;tr&gt;</code>, and have added the details-control class (Simplified code below)</p> <pre><code>&lt;tbody&gt; &lt;?php while($fetch = $query-&gt;fetch_array()) { /* processing to build 15 variables used as data in main row &lt;td&gt;s and 8 variables used in the "hidden" rows */ echo '&lt;tr id = "parent"&gt;'; echo '&lt;td class="details-control"&gt;&lt;/td&gt;'; /* taken from the DT example */ echo '&lt;td&gt;'.$MainVariable.'&lt;/td&gt;'; /* repeated for all 15 of the main row variables */ echo '&lt;/tr&gt;'; /* Now this should be the child row */ echo '&lt;tr id="child"&gt;'; echo '&lt;td colspan="5"&gt;'; echo 'Text: &lt;b&gt;'.$ChildVariable.'&lt;/b&gt;&lt;br /&gt;'; /* repeated for 6 of the child row variables */ echo '&lt;/td&gt;'; echo '&lt;td colspan="5"&gt;'; echo 'Text: &lt;b&gt;'.$ChildVariable.'&lt;/b&gt;&lt;br /&gt;'; /* repeated for remaining 2 of the child row variables */ echo '&lt;/td&gt;'; echo '&lt;td colspan="5"&gt;'; /* reserved for possibly more data */ echo '&lt;/td&gt;'; echo '&lt;/tr&gt;'; } ?&gt; &lt;/tbody&gt; </code></pre> <p>The Javascript I have tried is below</p> <pre><code>$(document).ready(function() { // Add event listener for opening and closing details $('#attendtbl').on('click', 'td.details-control', function () { var tr = $(this).closest('tr'); var row = table.row(tr); if (row.child.isShown()) { // This row is already open - close it row.child.hide(); tr.removeClass('shown'); } else { // Open this row row.child(format(tr.data('child-value'))).show(); tr.addClass('shown'); } }); }); </code></pre> <p>This shows all the data correctly, but all the child are shown displayed when the table loads, and the on('click' doesn't work.</p> <p>Looking at all the DataTables examples I can find all the data seems to be loaded by Javascript/AJAX. which is something I don't really want to do.</p> <p>I assume there must be a Javasript fault, but this is a new area for me.</p> </div>

使用datatables用ajax调用数据,不能形成表格

想使用datatables通过ajax生成表格,但是表格一直生成不出来,显示的是载入中…(下图)。由于是内网,只能拍照片没法截图。 ***** ![图片说明](https://img-ask.csdn.net/upload/201901/09/1547015472_655931.png) ***** ![图片说明](https://img-ask.csdn.net/upload/201901/09/1547015362_255719.png) ***** 这是js对应的列表代码片段 ``` "columns": [ {"data": "APP_ID"}, {"data": "APP_NAME"}, {"data": "APP_DESP"}, {"data": "APP_LABEL"}, {"data": "ORGANIZATION_ID"}, {"data": "ORGANIZATION_NAME"}, {"data": "ORGANIZATION_DESP"}, {"data": "ORGANIZATION_LABEL"} ] ``` 这是html对应的代码片段 ``` <table id="example" class="table table-striped table-bordered"> <thead> <tr> <th>应用ID</th> <th>应用名称</th> <th>应用描述</th> <th>应用注释</th> <th>机构ID</th> <th>机构名称</th> <th>机构描述</th> <th>机构英文名称</th> <th>操作</th> </tr> </thead> <tbody></tbody> </table> ```

如何使用jQuery DataTables插件实现服务器端处理?

<div class="post-text" itemprop="text"> <p>I am using the jQuery <a href="http://datatables.net" rel="nofollow">DataTables</a> plugin to display a set of results combined from multiple tables. I am trying to implement <a href="http://datatables.net/examples/data_sources/server_side.html" rel="nofollow">server-side processing</a> through the plugin to improve page load times. I can't quite figure out how to extrapolate the <a href="http://datatables.net/examples/data_sources/server_side.html" rel="nofollow">example</a> DataTables gives to my scenario. Any ideas/suggestions?</p> <p>Javascript:</p> <pre><code>$('#results').dataTable({ "sAjaxSource": "../server_processing.php", "bProcessing": true, "bServerSide": true, "bDeferRender": false, }) </code></pre> <p>Original PHP Function:</p> <pre><code>function build_data_list(){ global $org_id; global $dbh; global $req_ids; global $user_list; $sth = $dbh-&gt;query ("SELECT l4.name as L4name, l3.name as L3name, l2.name as L2name, l1.name as L1name, u.id, u.last_name, u.first_name, FROM user_grp_indx ugi, groups l4, groups l3, groups l2, groups l1, users p WHERE ugi.user_id = u.id AND l4.id = ugi.grp_id AND l4.parent = l3.id AND l3.parent = l2.id AND l2.parent = l1.id ORDER BY u.id", PDO::FETCH_ASSOC); $row = $sth-&gt;fetch(); $item['user_id'] = $row['id']; $item['user_info'] = '&lt;a href="../users/index.php?pq='; $item['user_info'] .= $row['id'].'"&gt;'; $item['user_info'] .= $row['last_name']. ", " . $row['first_name'] . "&lt;/a&gt;"; $item['l1_name'] = $row['L1name']; $item['l2_name'] = $row['L2name']; $item['l3_name'] = $row['L3name']; $item['l4_name'] = $row['L4name']; for ($i=0; $i &lt; sizeof($req_ids) ; $i++ ){ $item['req'.$i] = (chk_req_status($item['user_id'],$req_ids[$i]) ? "&lt;span title=\"Yes\"&gt;&lt;/span&gt;&lt;img src=\"../../media/icons/tick.png\" alt=\"Yes\" /&gt;" : "&lt;span title=\"No\"&gt;&lt;/span&gt;&lt;img src=\"../../media/icons/cross.png\" alt=\"No\" /&gt;"); } $old_L1id = $row['L1id']; $old_user_id = $row['id']; while ($row = $sth-&gt;fetch()){ $L1id = $row['L1id']; $user_id = $row['id']; if ($L1id == $old_L1id &amp;&amp; $user_id == $old_user_id ){ $item['l2_name'] .= "&lt;br/&gt;" . $row['L2name']; $item['l3_name'] .= "&lt;br/&gt;" . $row['L3name']; $item['l4_name'] .= "&lt;br/&gt;" . $row['L4name']; continue; } $user_list[] = $item; $old_L1id = $L1id; $old_user_id = $user_id; $item['user_id'] = $row['id']; $item['user_info'] = '&lt;a href="../users/index.php?pq='; $item['user_info'] .= $row['id'].'"&gt;'; $item['user_info'] .= $row['last_name']. ", " . $row['first_name'] . "&lt;/a&gt;"; //add inital level stuff to the new record. $item['l1_name'] = $row['L1name']; $item['l2_name'] = $row['L2name']; $item['l3_name'] = $row['L3name']; $item['l4_name'] = $row['L4name']; for ($i=0; $i &lt; sizeof($req_ids) ; $i++ ){ $item['req'.$i] = (chk_req_status($item['user_id'],$req_ids[$i]) ? "&lt;span title=\"Yes\"&gt;&lt;/span&gt;&lt;img src=\"../../media/icons/tick.png\" alt=\"Yes\" /&gt;" : "&lt;span title=\"No\"&gt;&lt;/span&gt;&lt;img src=\"../../media/icons/cross.png\" alt=\"No\" /&gt;"); } } } </code></pre> <p>Original HTML/PHP:</p> <pre><code>&lt;tbody&gt; &lt;?php foreach($user_list as $item){ print "&lt;tr&gt;"; print "&lt;td class=\"hidden\"&gt;{$item['user_id']}&lt;/td&gt;"; print "&lt;td&gt;{$item['user_info']}&lt;/td&gt;"; print "&lt;td&gt;{$item['l1_name']}&lt;/td&gt;"; print "&lt;td&gt;{$item['l2_name']}&lt;/td&gt;"; print "&lt;td&gt;{$item['l3_name']}&lt;/td&gt;"; print "&lt;td&gt;{$item['l4_name']}&lt;/td&gt;"; for ($i=0; $i &lt; sizeof($req_ids) ; $i++ ){ print '&lt;td&gt;'.( chk_req_status($item['user_id'],$req_ids[$i]) ? "&lt;span title=\"Yes\"&gt;&lt;/span&gt;&lt;img src=\"../../media/icons/tick.png\" alt=\"Yes\" /&gt;": "&lt;span title=\"No\"&gt;&lt;/span&gt;&lt;img src=\"../../media/icons/cross.png\" alt=\"No\" /&gt;").'&lt;/td&gt;'; } print "&lt;/tr&gt;"; } ?&gt; &lt;/tbody&gt; </code></pre> </div>

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

Linux面试题(2020最新版)

文章目录Linux 概述什么是LinuxUnix和Linux有什么区别?什么是 Linux 内核?Linux的基本组件是什么?Linux 的体系结构BASH和DOS之间的基本区别是什么?Linux 开机启动过程?Linux系统缺省的运行级别?Linux 使用的进程间通信方式?Linux 有哪些系统日志文件?Linux系统安装多个桌面环境有帮助吗?什么是交换空间?什么是root帐户什么是LILO?什...

Linux命令学习神器!命令看不懂直接给你解释!

大家都知道,Linux 系统有非常多的命令,而且每个命令又有非常多的用法,想要全部记住所有命令的所有用法,恐怕是一件不可能完成的任务。 一般情况下,我们学习一个命令时,要么直接百度去搜索它的用法,要么就直接用 man 命令去查看守冗长的帮助手册。这两个都可以实现我们的目标,但有没有更简便的方式呢? 答案是必须有的!今天给大家推荐一款有趣而实用学习神器 — kmdr,让你解锁 Linux 学习新姿势...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

史上最全的 python 基础知识汇总篇,没有比这再全面的了,建议收藏

网友们有福了,小编终于把基础篇的内容全部涉略了一遍,这是一篇关于基础知识的汇总的文章,请朋友们收下,不用客气,不过文章篇幅肯能会有点长,耐心阅读吧爬虫(七十)多进程multiproces...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

85后蒋凡:28岁实现财务自由、34岁成为阿里万亿电商帝国双掌门,他的人生底层逻辑是什么?...

蒋凡是何许人也? 2017年12月27日,在入职4年时间里,蒋凡开挂般坐上了淘宝总裁位置。 为此,时任阿里CEO张勇在任命书中力赞: 蒋凡加入阿里,始终保持创业者的冲劲,有敏锐的...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

新一代神器STM32CubeMonitor介绍、下载、安装和使用教程

关注、星标公众号,不错过精彩内容作者:黄工公众号:strongerHuang最近ST官网悄悄新上线了一款比较强大的工具:STM32CubeMonitor V1.0.0。经过我研究和使用之...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

大学一路走来,学习互联网全靠这几个网站,最终拿下了一把offer

大佬原来都是这样炼成的

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

什么时候跳槽,为什么离职,你想好了么?

都是出来打工的,多为自己着想

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你期望月薪4万,出门右拐,不送,这几个点,你也就是个初级的水平

先来看几个问题通过注解的方式注入依赖对象,介绍一下你知道的几种方式@Autowired和@Resource有何区别说一下@Autowired查找候选者的...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

立即提问
相关内容推荐