datatables搜索时如何过滤链接中<a>标签--[多列时]
来源:互联网 发布:c语言 绝对值 double 编辑:程序博客网 时间:2024/06/06 07:02
两种方案:
方案一:
http://stackoverflow.com/questions/12517407/how-do-i-ignore-html-when-filtering-a-jquery-data-table
mRender: function(data, type, full) { // If we're filtering, don't look at the HTML; only filter on the text return type == 'filter' ? $(data).text() : data }
方案二:
当表数据为动态时,涉及source赋值的问题。如何设计才能使后一列不会将前一列覆盖,还未解决方案。若有大侠知道答案,请给我点提示,谢谢啦。
当table为动态数据且链接仅为一列时,可参考:
http://stackoverflow.com/questions/16783202/how-to-search-only-text-in-jquery-datatables
当table固定且为多列时,方案如下:
表定义为:
<table id="search"> <thead> <tr> <th>search</th> <th>aaa</th> </tr> </thead> <tbody> <tr> <td><a href="www.google.com">b</a></td> <td ><a href="www.google.com">查看</a></td> </tr> <tr> <td><a href="www.google.com">c</a></td> <td><a href="www.google.com">查看</a></td> </tr> <tr> <td><a href="www.google.com">d</a></td> <td><a href="www.google.com">查看</a></td> </tr> </tbody></table>方法:
var filterFunc = function ( sData ){ return sData.replace(/\n/g," ").replace( /<.*?>/g, "" );};$(document).ready( function() { $('#search').dataTable ( { aoColumns:[ { 'aTargets': [1], 'mData': function(source, type, val){ if (type === 'set') { source[1] = new Object() source[1].value = val; source[1].value_display = val; source.value_filter = val=="" ? "" : filterFunc(val); return;}else if (type === 'display') { return source[1].value_display;}else if (type === 'filter') { return source.value_filter;}// 'sort', 'type' and undefined all just use the integerreturn source[1].value; } }, { 'aTargets': [2], 'mData': function(source, type, val){ if (type === 'set') { source[2] = new Object() source[2].value = val; source[2].value_display = val; source.value_filter = val=="" ? "" : filterFunc(val); return;}else if (type === 'display') { return source[2].value_display;}else if (type === 'filter') { return source.value_filter;}// 'sort', 'type' and undefined all just use the integerreturn source[2].value; } }, ] } ); });
参考:
http://www.datatables.net/forums/discussion/comment/43333
http://stackoverflow.com/questions/16783202/how-to-search-only-text-in-jquery-datatables
- datatables搜索时如何过滤链接中<a>标签--[多列时]
- 如何过滤链接中出现的sessionid
- 关于Android中如何过滤HTML标签
- 在input 标签中添加 a标签跳转链接
- 链接<a>标签
- a标签链接跳转
- a标签链接QQ
- a标签<链接>
- a 标签作为按钮执行js时,如何避免链接出现#
- 如何隐藏链接标签(A)的焦点
- JS如何获取A标签里面的链接属性
- Java过滤<a>标签问题
- rails中如何在a标签中添加其他标签
- html中a标签如何设置行宽高
- FLEX在textArea中使用a标签链接外部资源
- Perl如何过滤html标签
- js中动态生成<a>标签并动态打开<a>标签中的链接
- a标签里面嵌套一个a标签,点击子链接标签时,同时触发了父标签a
- 第十四周 创建一个长度为20的整形数组
- LVDS 知识简介--------------
- 添加三方库的问题
- c++ 定义指向类成员的指针
- 网络爬虫技术浅析
- datatables搜索时如何过滤链接中<a>标签--[多列时]
- Android Apk反编译与重编译
- ~~理解~VMWare的3种网络模型~~~~~【图】 和~~虚拟机本地连接IP设置
- C语言学习过程
- PHP二进制上传图片 AND 再把二进制转换成图片详细介绍(案例)
- 使用javassist生成新类
- iOS开发笔记
- 项目中Mybatis、Proxool配置以及dao层的封装实例
- 我的android 第14天 - 使用SQLiteDatabase操作SQLite数据库