数据表重置搜索按钮

编程入门 行业动态 更新时间:2024-10-26 05:19:10
数据表重置搜索按钮 - 导致IE7中出现jQuery错误(Datatables reset search button - causes jQuery error in IE7)

我已经使用数据表和行分组为项目添加了重置搜索按钮。 它在除IE7之外的所有浏览器中都能正常工作 在IE7中,重置搜索按钮和全部展开/全部合同按钮消失。

调试器(IE控制台)显示此错误:

SCRIPT87:参数无效

jquery.min.js,第2行,第31006行

看来调用函数ResetSearchField(); 是违规的来源。

有人能帮我解决这个问题吗? 我将衷心感谢您的帮助! 我已经设置了一个jsfiddle来说明问题: http : //jsfiddle.net/lbriquet/SG8Dm/4/

这是我正在使用的代码:

$(document).ready(function() { var oTable = $('#example').dataTable({ "oLanguage": { "sSearch": " Table search:" }, "bPaginate": false, "iDisplayLength": 100, "bLengthChange": false, "bJQueryUI": true, "sDom": 'Tlfrtip' }).rowGrouping({ bExpandableGrouping: true, bExpandSingleGroup: false, iExpandGroupOffset: -1, asExpandedGroups: [""] }); ResetSearchField(); $('.expandedOrCollapsedGroup').live('click', function() { if ($(this).hasClass('collapsed')) { $(this).addClass('expanded').removeClass('collapsed').val('Collapse All').parents('.dataTables_wrapper').find('.collapsed-group').trigger('click'); } else { $(this).addClass('collapsed').removeClass('expanded').val('Expand All').parents('.dataTables_wrapper').find('.expanded-group').trigger('click'); } }); oTable.live('filter', function() { clearTimeout(oTable.data('timeout')); var timeoutId = setTimeout(function() { if ($('label:contains(Table search: ) input').val() != '') { $('.group-item-expander.collapsed-group').trigger('click'); } else { $('.group-item-expander.expanded-group').trigger('click'); } }, 1000); oTable.data('timeout', timeoutId); }); $("#resetsearch").live('click', function(e) { oTable.fnFilter(''); GridRowCount(); }); GridRowCount(); new FixedHeader(oTable); }); function GridRowCount() { $('span.rowCount-grid').remove(); $('input.expandedOrCollapsedGroup').remove(); $('.dataTables_wrapper').find('[id|=group-id]').each(function() { var rowCount = $(this).nextUntil('[id|=group-id]').length; $(this).find('td').append($('<div />', { 'class': 'rowCount-grid' }).prepend($('<b />', { 'text': "(" + rowCount + ")" }))); }); $('.dataTables_wrapper').find('.dataTables_filter').prepend($('<input />', { 'type': 'button', 'class': 'expandedOrCollapsedGroup collapsed', 'value': 'Expand All' })); }; function ResetSearchField() { $('.dataTables_wrapper').find('.dataTables_filter').append($('<input />', { 'type': 'submit', 'class': 'ui-icon ui-icon-closethick float-right', 'id': 'resetsearch', 'border': 'none' })); };

I've added a reset search button to a project using datatables and rowgrouping. It works fine in all browsers except IE7. In IE7 the reset search button AND the Expand All/Contract All button disappears.

The debugger (IE console) shows this error:

SCRIPT87: Invalid argument

jquery.min.js, line 2 character 31006

It seems that calling the function ResetSearchField(); is the offending source.

Can someone give me a hand at solving this problem? I would really appreciate your help! I've set up a jsfiddle to illustrate the problem: http://jsfiddle.net/lbriquet/SG8Dm/4/

Here is the code I'm using:

$(document).ready(function() { var oTable = $('#example').dataTable({ "oLanguage": { "sSearch": " Table search:" }, "bPaginate": false, "iDisplayLength": 100, "bLengthChange": false, "bJQueryUI": true, "sDom": 'Tlfrtip' }).rowGrouping({ bExpandableGrouping: true, bExpandSingleGroup: false, iExpandGroupOffset: -1, asExpandedGroups: [""] }); ResetSearchField(); $('.expandedOrCollapsedGroup').live('click', function() { if ($(this).hasClass('collapsed')) { $(this).addClass('expanded').removeClass('collapsed').val('Collapse All').parents('.dataTables_wrapper').find('.collapsed-group').trigger('click'); } else { $(this).addClass('collapsed').removeClass('expanded').val('Expand All').parents('.dataTables_wrapper').find('.expanded-group').trigger('click'); } }); oTable.live('filter', function() { clearTimeout(oTable.data('timeout')); var timeoutId = setTimeout(function() { if ($('label:contains(Table search: ) input').val() != '') { $('.group-item-expander.collapsed-group').trigger('click'); } else { $('.group-item-expander.expanded-group').trigger('click'); } }, 1000); oTable.data('timeout', timeoutId); }); $("#resetsearch").live('click', function(e) { oTable.fnFilter(''); GridRowCount(); }); GridRowCount(); new FixedHeader(oTable); }); function GridRowCount() { $('span.rowCount-grid').remove(); $('input.expandedOrCollapsedGroup').remove(); $('.dataTables_wrapper').find('[id|=group-id]').each(function() { var rowCount = $(this).nextUntil('[id|=group-id]').length; $(this).find('td').append($('<div />', { 'class': 'rowCount-grid' }).prepend($('<b />', { 'text': "(" + rowCount + ")" }))); }); $('.dataTables_wrapper').find('.dataTables_filter').prepend($('<input />', { 'type': 'button', 'class': 'expandedOrCollapsedGroup collapsed', 'value': 'Expand All' })); }; function ResetSearchField() { $('.dataTables_wrapper').find('.dataTables_filter').append($('<input />', { 'type': 'submit', 'class': 'ui-icon ui-icon-closethick float-right', 'id': 'resetsearch', 'border': 'none' })); };

最满意答案

我找到了解决方案! 在脚本调用后,我禁用了函数ResetSearchField,如下所示:

<!--[if IE 7]> <script type="text/javascript"> function ResetSearchField() { } </script> <![endif]-->

I found the solution! After the script call I disabled the function ResetSearchField like this:

<!--[if IE 7]> <script type="text/javascript"> function ResetSearchField() { } </script> <![endif]-->

更多推荐

本文发布于:2023-08-04 15:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1417895.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据表   按钮

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!