如何使用JQuery DataTables根据每个单元格中的值的子字符串对列进行排序 [英] How to sort a column base on a substring of the values in each cell with JQuery DataTables
本文介绍了如何使用JQuery DataTables根据每个单元格中的值的子字符串对列进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一列,其中包含格式为P< 2位数字年份>-< 4位数字标识符>的对象标识符,例如
Suppose I have a column that contains object identifiers in the format P<2 digit year>-<4 digit identifier>, e.g.
P12-3767
我正在使用JQuery的1.9.1版本 DataTables插件进行排序和分页.有没有一种方法可以忽略单元格值的前4个字符("P12-"部分),以便仅对标识符的数字部分进行有效排序?
I am using version 1.9.1 of the JQuery DataTables plugin for sorting and pagination. Is there a way that I can ignore the first 4 characters (the "P12-" part) of the cell values so that I'm effectively sorting on just the numeric part of the identifier?
推荐答案
在jsp页面中导入jstl函数
Import jstl functions in the jsp page
<%@ taglib uri = "http://java.sun.com/jsp/jstl/functions" prefix = "fn" %>
包含data-sort属性,用于指定要排序的子字符串
Include data-sort attribute specifying the substring to sort
<td data-sort="${fn:substringAfter('P12-3767', 'P12-')}">P12-3767</td>
这篇关于如何使用JQuery DataTables根据每个单元格中的值的子字符串对列进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文