Skip to Content
0

How to iterate all filtered rows in Grid

Feb 01, 2017 at 05:20 PM

126

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Pedro Magueija Feb 03, 2017 at 07:30 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

0
Pedro Magueija Mar 01, 2017 at 02:53 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

0
DIEGO LOTHER Mar 02, 2017 at 07:02 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

0