I am using AG Grid getSelectedRows()
to get the selected rows data.
The issue is when i uncheck some columns to hide it using columns tool Panels, the getSelectedRows()
it will retrive all the row vlaues, i mean the hidden and the visibles rows valus.
my quiestion, is there any way to get visibles Rows data only?
As the below image shows, i need to get only Country, year and date row values instead of getting all columns
const selectedRows: any = this.gridOptions.api.getSelectedRows();
I am using AG Grid getSelectedRows()
to get the selected rows data.
The issue is when i uncheck some columns to hide it using columns tool Panels, the getSelectedRows()
it will retrive all the row vlaues, i mean the hidden and the visibles rows valus.
my quiestion, is there any way to get visibles Rows data only?
As the below image shows, i need to get only Country, year and date row values instead of getting all columns
const selectedRows: any = this.gridOptions.api.getSelectedRows();
https://plnkr.co/edit/0wPm6bVrdPwBjIOSqG2L?p=preview
Share Improve this question edited Oct 29, 2019 at 12:53 johannchopin 14.9k11 gold badges62 silver badges121 bronze badges asked Oct 29, 2019 at 12:39 A.AlshaikhliA.Alshaikhli 4374 gold badges9 silver badges19 bronze badges 3- Could you clarify what you need in your output? Are you wanting to simply limit your results to country, year, and date? I'll post an answer, but I'll be happy to work with you and revise it as needed – Damian C Commented Oct 31, 2019 at 3:28
- @shadowfox476 thank you so much for your Help. Actually your below code will work fine if we have a static number of columns. but the problem is that columns are generated dynamically, so I don't know if it is possible Returns all row values of the columns are currently displayed I found something but I don't know if it's the best practice to do that. we use getAllDisplayedColumns() to get all displayed columns name in array then filter it over getSelectedRows(). do you think it is a good solution to do that? Thanks – A.Alshaikhli Commented Nov 3, 2019 at 9:34
- 1 If that call is there then I would assume it's okay to use it. As a performance tip, see if you can only run that method once, instead of every row. All rows will have the same columns – Damian C Commented Nov 3, 2019 at 12:28
1 Answer
Reset to default 5Looks like you can use getRenderedNodes() and then use a mapper
this.gridApi.getRenderedNodes().map((row) => {
return {
country: row.data.country,
year: row.data.year,
date: row.data.date
};
});