我有一个像这样的HTML表
HTML表输出如下:
Work Order PROCESS_ID_D.PROCESS_ID_H Mar 2013 Apr 2013
V100224 $0.00 $0.00 $0.00
A100225 $1.00 $0.00 $819,250.90
A100225 $0.00 $703,648.70 $753,909.31
Z100123 $1.00 $0.00 $0.00
D100358 $0.00 $0.00 $0.00
Z100123 $0.00 $0.00 $0.00
对HTML表格数据进行排序后如下:
Work Order PROCESS_ID_D.PROCESS_ID_H Mar 2013 Apr 2013
A100225 $1.00 $0.00 $819,250.90
A100225 $0.00 $703,648.70 $753,909.31
D100358 $0.00 $0.00 $0.00
V100224 $0.00 $0.00 $0.00
Z100123 $1.00 $0.00 $0.00
Z100123 $0.00 $0.00 $0.00
结果如下:
Work Order PROCESS_ID_D.PROCESS_ID_H Mar 2013 Apr 2013
A100225 $0.00 $703,648.70 $753,909.31
A100225 $1.00 $0.00 $819,250.90
V100224 $0.00 $0.00 $0.00
D100358 $0.00 $0.00 $0.00
Z100123 $0.00 $0.00 $0.00
Z100123 $1.00 $0.00 $0.00
我的要求是基于工作订单列和PROCESS_ID_D.PROCESS_ID_H列进行排序,它们是无默认排序的点击操作。请帮帮我。
谢谢
答案 0 :(得分:0)
只需按顺序连接两列的值:
var tda = $(a).find('td:eq(0)').text() + $(a).find('td:eq(1)').text();
var tdb = $(b).find('td:eq(0)').text() + $(b).find('td:eq(1)').text();
return (tda > tdb) ? 1 : (tda < tdb) ? -1 : 0;
JSFiddle:http://jsfiddle.net/3Lghgfdu/1/