2013-03-14 26 views
0

的Jquery的tablesorter的Jquery的tablesorter文本提取

我使用jQuery的tablesorter 2.0,我需要用具有输入列进行排序表和选择,并打破标签。

我尝试了很多使用文本提取的方式。但我没有得到想要的结果。它将内容视为文本。

这是我的td,想要对输入的文本数据进行排序。

<td> 
    <input type=text maxlength=2 size=1 value="10"><br> 
    <select > 
     <option value="D">D</option> 
     <option value="S"> s</option> 
    </select> 
</td> 

请注意。帮帮我。

+1

你试过了什么? – Stanley 2013-03-14 20:07:27

+0

请提供一些HTML,或者甚至更好的表格演示。 – Mottie 2013-03-15 00:13:17

回答

0

我认为解析器会是一个更好的主意。

$.tablesorter.addParser({ 
    id: "input", 
    is: function(s, table, cell){ 
     return false; 
    }, 
    format: function(s, table, cell) { 
     return $(cell).find('input').val() || s; 
    }, 
    type: "text" 
}); 

然后初始化像这样的表:

$('table').tablesorter({ 
    headers: { 
     // 0 is the index of the first column (zero-based) 
     0: { sorter: 'input' } 
    } 
}); 

注:如果您使用的tablesorter V2.0.5,那么上面的解析器将工作得很好,但如果你使用“updateCell”方法,它不会工作。