StrataFrame Forum

CurrentRowIndex

http://forum.strataframe.net/Topic9319.aspx

By Larry Caylor - 6/5/2007

When I use the Add() method to add a new row to a BO that has a Sort defined, the CurrentRowIndex is being set to zero rather than the actual index of the new row. If a Filter is added to the BO rather than a sort, the CurrentRowIndex is maintained correctly.

I'm on v1.61 pre-release.

-Larry

By Larry Caylor - 6/5/2007

After a little more testing I found my original tests were incorrect and that a Filter causes the same behavior as a SortBlush  I'm assuming that this is probably by design and you can't add rows to sorted or filtered BOs.

-Larry

By Trent L. Taylor - 6/5/2007

Yup....if you recall, we actually touched on this briefly during class because I too have been there before.  When you add the new record the filter is immediately applied.
By StrataFrame Team - 6/5/2007

No, we actually try to handle the situations where a new row might be filtered out or sorted, however, the following code is called right before the SetDefaultValues() is raised, so it will be right up until you set a field within the SetDefaultValues().  The problem with having a sort or filter set when you're adding rows is that the record might change each time you set another column on the business object, causing the view to resort or refilter the row.

                '-- Start from the back of the list and cycle through the rows to find the row index
                For lnCnt = Me.Count - 1 To 0 Step -1
                    If _CurrentDataTable.DefaultView(lnCnt).Row Is loRow Then
                        '-- We've found our row index
                        lnRowIndex = lnCnt
                        Exit For
                    End If
                Next

                '-- Set the row index to the index of the new row
                _CurrentRowIndex = lnRowIndex

By Larry Caylor - 6/5/2007

Thanks for the explanation. It must have been right after lunch when we went over that in classDoze Conceptually I can see how you could handle a sorted BO since a Sort would never remove a row from the CurrentView, but a Filter would present some issues.

-Larry

By Chan - 1/4/2009

Hi,

May I know what is the "workaround"?



Thank you
By Edhy Rijo - 1/4/2009

Chan (01/04/2009)
May I know what is the "workaround"?

Hi Chan,

I guess it is to reset the filter prior adding then set the filter again, here is a pseudo code:

DIM strTempFilter as String = MyBO.Filter

MyBO.Filter = String.Empty

MyBO.Add()

MyBO.Filter = strTempFilter