cancel
Showing results for 
Search instead for 
Did you mean: 

Power Builder 12.5 - Return selected row after remove and apply filter

sofhin
Discoverer
0 Kudos

Hi all

I have a window which consists of multiple datawindow. When I click on the dw, the row changed, it gets the row correctly However, when I save this transaction, the row will not stay in the same row, but returning to the first row.

I do reset filter before save, and when remove the filter (setFilter('')), it triggers rowfocuschanged event, where getrow() and currentrow returns 1 instead of 4 (let's say selected row is 4).

It is the same when I set the filter.

I was thinking of the buffer, primary and filter buffer, but having no idea on how to solve it.

Please advise.

Thank you in advance

chris_keating
Advisor
Advisor
0 Kudos

This has nothing to do with the filter. The issue is that the selected row(s) are cleared when the datawindow is retrieved. The filter, behind the scenes, retrieves all rows and then applies the filter - clearing the selected row(s) in the process. If you need to keep the selected row(s), you will need to track what rows are selected before invoking <dw>.Filter(...) and reselect those rows after the filter is applied (even if that filter is a reset).

sofhin
Discoverer
0 Kudos

Hi

Thank you for the reply.

Oh, I tried to store currentrow to a variable before invoke Filter().

However, when I call to get the variable value from the window, it becomes the original value.

For instance, when I declare long l_currentRow, the default value is 0, before invoke Filter(), the value is 4.

When I call object.l_currentRow, the value will be 0.

Thank you

chris_keating
Advisor
Advisor
0 Kudos

As you have discovered, the CurrentRow does not uniquely identify a row in a filtered datawindow as that value changes depending on where that row falls in the current set of rows.

You will need some mechanism to identify the rows uniquely no matter the state of the filter. One way is to use the PKs for this purpose - each for a single table DW but more complex when there are joins to other tables. Another option is to create a hash based on columns known to uniquely identify the row and use it to identify the row regardless of the filtering,

sofhin
Discoverer
0 Kudos

Oh....

So later we can identify through it.

Thank you so much.

Your answer helped a lot!

Accepted Solutions (0)

Answers (0)