109
Views
3
Comments
Solved
[OutSystems Data Grid] Get a particular Column Data as a List OnFiltersChange
data-grid-reactive
Reactive icon
Forge component by Gonçalo Martins
Service Studio Version
11.54.12 (Build 62475)

Hi, how do I get all data of one particular column as a list OnFiltersChange? 

I have been looking through the GridAPI and DataGrid documentation, but I could not find a suitable method.

Things I've tried:

  1. Get total records number.
  2. Loop through the column to get the current row value and append to a list.

But the problem is the cells.getCellData function is only getting data on the current page, so when the count exceeds the row number of current page, it will return null.

Are there other methods that I can use to retrieving all data from a particular column after every filter change? Thank you.

Solution

Hi @Max Chia 

The method you're trying to use is only applicable to the current view.

I'm not sure what you want to achieve but you can see the information about all cells in a particular column by looking at:

let obj = OutSystems.GridAPI.ColumnManager.GetColumnById('ColName')._grid._dataSource._ds;

const names = [];

for (const key in obj) {
  if (obj.hasOwnProperty(key)) {
    const item = obj[key];
    if ('NAME' in item) {
      names.push(item.NAME);
    }
  }
}

console.log(names);

Hope it helps!

Cheers,
GM

Hi Goncalo,

Thanks for the solution. However, I think I didn't state my requirement clear enough. Sorry about that.

Currently the solution will always return all data from the data source. But what I want to achieve is to return the filtered data after the user performs any filtering on the grid. 

For example, my grid has 100 records, after adding some filters, there are 30 matching records, then it will return the column's data of those 30 records instead of all data from the data source.

In another word, every time the OnFitlersChange event is triggered, it will return the filtered data of that particular column.

Is it possible to achieve this? Sorry for my bad English.

Hi Max

Did you find any solution to this? If found then please share.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.