0

行が動的にフィルタリングされ、列見出しのすぐ下にセルとして表示されるときに、mottie の jquery tablesorter を使用して各列の新しい最大値を把握する簡単な方法があったかどうか疑問に思っています。行がフィルタリングされると、各列の最大値が変化します。

4

1 に答える 1

1

次のようなものを試してください ( demo ):

var $t = $('table'),
    maxColumn = 1, // zero-based index of column number
    getMax = function () {
        var c = $t[0].config,
            col = c.$tbodies.find('tr:visible').map(function () {
                return parseInt($(this).find('td:eq(' + maxColumn + ')').text(), 10);
            }).get();
        c.$headers.eq(maxColumn).find('span').text( Math.max.apply(Math, col) );
    };
$t
    .on('filterEnd', function () {
        getMax();
    })
    .tablesorter({
        theme: 'blackice',
        widgets: ['zebra', 'filter'],
        initialized: function () {
            getMax();
        }
    });
于 2013-05-22T20:36:46.770 に答える