datatables

DataTables Pager Showing Many Pages when there is Only One

落花浮王杯 提交于 2020-04-17 19:00:18
问题 This is a weird one. I'm using datatables v1.10.19 with jQuery 3.3.1 and Bootstrap 3.3.7 My datatables grid is configured to display 1000 records (but you can change it to 2500, 5000 and "all"). I've only got about 60 records in my database. It is using Server-Side processing to retrieve data. When the grid loads, the pager displays 5 buttons plus an ellipses (as if there is even more). And even weirder, if I change the drop-down to display "all" records, it acts as I would expect i.e. the

dataTables中文排序以及中英文混排乱序问题解决

|▌冷眼眸甩不掉的悲伤 提交于 2020-04-12 13:16:20
dataTables是个强大的JQuery表格插件,但是不支持中文排序,这个比较令人头疼。 这里针对几种常见的数据格式写了一个dataTables的中文排序方法: //添加中文排序 function addChieseAsc() { jQuery.fn.dataTableExt.oSort['chinese-asc'] = function(x, y) { x = (x instanceof Array) ? x[0] : x == '-' ? 'z' : x; //z的ASCII码值最大 y = (y instanceof Array) ? y[0] : y == '-' ? 'z' : y; //javascript自带的中文比较函数,具体用法可自行查阅了解 return x.localeCompare(y); }; jQuery.fn.dataTableExt.oSort['chinese-desc'] = function(x, y) { x = (x instanceof Array) ? x[0] : x == '-' ? 'z' : x; y = (y instanceof Array) ? y[0] : y == '-' ? 'z' : y; return y.localeCompare(x); }; // aTypes是插件存放表格内容类型的数组 //

Angular Datatable的一些问题

╄→尐↘猪︶ㄣ 提交于 2020-03-29 08:59:29
这几天改bug中发现的一些问题,小结一下。从简单到复杂逐个讲。 angular datatable实质上是对jquery库的包装,但包装后不太好用,定制功能比较麻烦。 1. 基本用法 最简单的用法,大致就是template里: <table datatable [dtOptions]="dtOptions"> component里: dtOptions: DataTables.Settings; 最基本的就这两句,其他代码都不用改,table就自然有了搜索,按列排序等功能。 2. css 如果要用分页功能,一是dtOptions需配置一下: dtOptions: DataTables.Settings = {paging: true}; 二是需要在angular.json里加上css路径,不然分页栏排版错乱: "styles": [ "node_modules/datatables.net-dt/css/jquery.dataTables.css", 3. 去掉(不显示)上方每页显示N条记录的下拉选择框 dtOptions配置: dtOptions: DataTables.Settings = {lengthChange: false;} 4.避免和已有的css冲突 原来的table已经定义了一套css,加上datatable属性后,原有的css被破坏了。我用个笨办法

datatables ajax后端请求那些坑

て烟熏妆下的殇ゞ 提交于 2020-03-25 10:31:44
在对datatables做后端数据填充的时候,遇到一个,翻页问题。在多次操作翻页后,总是提示加载中。反了很多博客没有找到原因。 经过测试,发现原来自己坑了自己。 代码如下: datatables : { init : function (table_id,ajax_url,columns,buttons,searchParams) { if(null == columns || undefined == columns){ columns = []; } if(null == buttons || undefined == buttons){ buttons = []; } var $t_table = $("#" + table_id); var $api_table = $t_table.dataTable({ language: { "sProcessing": "处理中...", "sLengthMenu": "每页 _MENU_ 项", "sZeroRecords": "没有匹配结果", "sInfo": "当前显示第 _START_ 至 _END_ 项,共 _TOTAL_ 项。", "sInfoEmpty": "当前显示第 0 至 0 项,共 0 项", "sInfoFiltered": "(由 _MAX_ 项结果过滤)", "sInfoPostFix": "",

datatables 配套bootstrap3样式使用小结(1)

匆匆过客 提交于 2020-03-20 20:16:28
今天介绍汇总一下datatables。 网址: www.datatables.net 公司CMS内容资讯站的后台管理界面用了大量的table来管理数据,试用了之后,感觉挺不错,推荐一下。 先上一个基本的效果图. (图片太宽了,换了另一个模板) 介绍一下这个demo的实现。 首先是引用 js+css。 js有4个,①jquery,②bootstrap3,③datatables的js,④datatables对应bootstrap样式时用的。 为了说明问题,就不放bundle里面了。 <script src="~/Scripts/jquery-1.10.2.js"></script> <script src="~/Scripts/bootstrap.js"></script> <script src="~/Content/datatables/js/jquery.dataTables.js"></script> <script src="~/Content/datatables/js/dataTables.bootstrap.js"></script> 然后是css。 有2个,①bootstrap3,②datatables对应bootstrap样式(要用这个替换datatables默认的样式,否则会出现右下角的分页样式margin很大的情况。) <link href="~/Content

Parent/Child Rows in R

陌路散爱 提交于 2020-03-17 03:06:03
问题 I'm trying to use some JavaScript to create a nice table layout with parents/child nesting. I only need one child per parent. I have two data frames. The goal here is to make a table that combines these two data frames. So far I am able to do that. However, the problem here is that I can only get the code to work for one row in df1. When I go to add in another row to df1 I get Error in data.frame: arguments imply differing number of rows: 1, 2 . For example, the desired result is achieved

Parent/Child Rows in R

做~自己de王妃 提交于 2020-03-17 03:05:33
问题 I'm trying to use some JavaScript to create a nice table layout with parents/child nesting. I only need one child per parent. I have two data frames. The goal here is to make a table that combines these two data frames. So far I am able to do that. However, the problem here is that I can only get the code to work for one row in df1. When I go to add in another row to df1 I get Error in data.frame: arguments imply differing number of rows: 1, 2 . For example, the desired result is achieved

Parent/Child Rows in R

有些话、适合烂在心里 提交于 2020-03-17 03:05:04
问题 I'm trying to use some JavaScript to create a nice table layout with parents/child nesting. I only need one child per parent. I have two data frames. The goal here is to make a table that combines these two data frames. So far I am able to do that. However, the problem here is that I can only get the code to work for one row in df1. When I go to add in another row to df1 I get Error in data.frame: arguments imply differing number of rows: 1, 2 . For example, the desired result is achieved

How to add a column SUM feature to my datatable?

佐手、 提交于 2020-03-05 05:29:04
问题 I have created a datatable which has a multi search feature in the footer and I would like to have a feature which adds up all the salaries of what is currently displayed or searched. I am not sure how to do that. Here is my HTML code for the table <script src="https://code.jquery.com/jquery-3.3.1.js"></script> <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script> <script src="./search.js"></script> <link href="https://cdn.datatables.net/1.10.19/css/jquery

Unable to make service call in Data tables server side processing

吃可爱长大的小学妹 提交于 2020-03-05 03:11:09
问题 Javascript $('#grid').DataTable({ "processing": true, "destroy": true, "scrollY": true, "scrollX": true, "serverSide": true, "paging": true, "pageLength": 20, "lengthChange": false, "language": { search: '', searchPlaceholder: "Search..." }, "ajax": { "url":'api/Default/EmployeeDetails', "contentType": "application/json", "type": 'POST', "dataType": "json", "data": function (d) { debugger; return JSON.stringify(d); }, "dataSrc": function (json) { debugger; //json.draw = json.draw; //json