Extracting filtered table data

怎甘沉沦 提交于 2019-12-06 16:27:55

问题


I was wondering if it is possible to extract the filtered data from a table which has been filtered using the JQuery tableSorter plugin/widget.

I have a large table shown, and I then filter/sort it using the normal tablesorter functionality - but what I would like to do is be able to take this smaller table and export some data from it

it's a list of members - so I want to be able to export data (eg email addresses) from the filtered (eg all over a certain age) data so I can then send emails to these select people without having to manually type them etc.

Is this easy to do? I don't mind if I have to write something myself if someone can point me in the right direction on where to start etc?

Thanks for any help you can give, Chris


回答1:


All you would need to do is find the visible table cells and save their data.

I wasn't sure how you wanted the data to be exported, so I opted for csv in this demo:

$('.export').on('click', function(){
    var csv = [];
    // find only visible rows; we're ignoring filtered/hidden rows
    $('table').find('tbody tr:visible').find('td').each(function(){
        csv.push( $(this).text() );
    });
    // do what you want with the csv data here
    $('textarea').val( csv.join(',') )
});


来源:https://stackoverflow.com/questions/14655988/extracting-filtered-table-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!