cancel
Showing results for 
Search instead for 
Did you mean: 

How to iterate all filtered rows in Grid

paolo_fornari3
Participant
0 Kudos

Hi,

I have some users using filter table icon (funnel) to filter grid in my user forms.

I want to iterate all 'filtered' rows to do some operations but i didn't find a way.

Is it possible?

Thank you

Paolo

Accepted Solutions (0)

Answers (4)

Answers (4)

ozer_aydin
Explorer
0 Kudos

Hi,

did you solved this situation.. Now i need that too.

paolo_fornari3
Participant

Hi Ozer,

I didn't find a solution.

I just came up disabling funnel icon and implementing by myself the filters I needed.

Didn't check if now SDK provide some ways to approach the issue.

ozer_aydin
Explorer
0 Kudos

Hi Paolo,

i did it same as you did,

thanx for answer.

former_member185682
Active Contributor
0 Kudos

Hi Paolo,

Maybe this is not a good option, but you can do something like this:

1. Replace you grid by a matrix control.

2. Bind your columns with the columns of your datatable.

The you can use a code like this:

                SAPbouiCOM.Matrix oMtx = oForm.Items.Item("your mtx").Specific;
                for (int i = 1; i <= oMtx.VisualRowCount; i++)
                {
                    string value = (oMtx.Columns.Item("your column id").Cells.Item(i).Specific).Value;
                }

With matrix the visible rows will be the first lines. Then iterate just until the value of property VisualRowCount, and read the values directly from matrix. This method can be slow depending the number of registers.

Hope it helps.

Kind Regards,

Diego Lother

paolo_fornari3
Participant
0 Kudos

Hi Diego,

Thank you for your suggestion, at the moment Grid is working good for me, so i don't want to replace it with Matrix.

I will eventually consider it in the future, hoping meanwhile SDK will support it....

Paolo

pedro_magueija
Active Contributor
0 Kudos

Hi Paolo,

The datatable will always contain all the rows. The "filter" is only visual. So what I was proposing is that you iterate over the rows on the grid and use the function above to get the index of that row on the datatable. The function acts like a map between the index you seen on screen (the row index) and the index of the data row (the row on the datatable).

Again note that I haven't tested if the function in question takes into consideration the filter.

Pedro Magueija

LinkedIn | Twitter | Blog

paolo_fornari3
Participant
0 Kudos

Hi Pedro,

I've tryed with a grid with 6 rows, filtered it to obtain only 1 row.

From UI SDK when calling MyGrid.Rows.Count I still get 6 rows, so SDK seems not able to get only filtered rows.

Do you agree with me?

Thank you

pedro_magueija
Active Contributor
0 Kudos

Hi Paolo,

I've never tried to do this, but there is a GetDataTableRow(rowIndex) that returns the position of the row of the grid on the data table.

Are you using this method when iterating over the grid rows?

Pedro Magueija

LinkedIn | Twitter | Blog

paolo_fornari3
Participant
0 Kudos

Hi Pedro,

I'm just iterating datatable, sorry i don't understand your proposal, it seems like through sdk I always get all rows filtered or not.

thank you