priyanshi
priyanshi

Reputation: 1

In tabulator how to get a filter selected data

In tabulator how to get a filter selected data using getSelectedData() function.I will try to pass a true value but does not working. Thank you.

Upvotes: 0

Views: 3550

Answers (2)

dr_cornelius
dr_cornelius

Reputation: 75

I couldn't get Oli's answer to work, but the code below worked for me, by using findIndex in the last line instead of indexOf:

var filteredData= table.getData('active');
var selectedData = table.getSelectedData();

var filterSelectedData = filteredData.filter(x => -1 !== selectedData.findIndex(y => y.id === x.id));

Upvotes: 1

Oli Folkerd
Oli Folkerd

Reputation: 8348

This is not possible directly on tabulator but is easy to achieve.

If you use getSelectedData() to retrieve the selected data, the getData(true) to get the filtered data, you can then filter one from the other to get the filtered selected row data.

var filteredData= table.getData(true);
var selectedData = table.getSelectedData();

var filterSelectedData = filteredData.filter(value => -1 !== selectedData .indexOf(value))

Upvotes: 3

Related Questions