0

Jquery テーブルソーター

私はJquery tablesorter 2.0を使用しています.inputとselectとbreakタグを持つ列でテーブルをソートする必要があります。

テキスト抽出を使用する多くの方法を試しました。しかし、目的の結果が得られません。コンテンツをテキストと見なします。

これは私の 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>

お願いします。ヘルプ。

4

1 に答える 1

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」メソッドを使用すると機能しません。

于 2013-03-23T19:42:22.957 に答える