Juan Carlos Pazos
|
|
Group: Forum Members
Posts: 144,
Visits: 227
|
Hi I have a curious situation. I have a table for families, the BO has this method: Public Sub FillAllRecords()Me.FillDataTable("SELECT * FROM Familias ORDER BY Apellidos")End SubI add three records, one begin with H, second with D and las one with A. Every time I load the maintenance form, goes to the second record in this case the one beginning with D, the order is correct, the first record is the one with A but I can not understand why goes to the second one. Regards
Everything is possible, just keep trying...
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
You can actually find your answer to this throughout the forum....it becomes a common post. You have a sort or filter set on your BO which changes the order of the internal data table, but the CurrentRowIndex is left the same. So when you add a new record or modify a column that is part of the sort or filter, you will either need to clear the sort or filter or take this into account. This is a very common thing that we see out here on the forum, but I am 99.99% confident that you have a filter or sort applied to he BO or something along those lines that is changing the order of the records in the BO.
|
|
|
Juan Carlos Pazos
|
|
Group: Forum Members
Posts: 144,
Visits: 227
|
Hi Trent Sorry but I dont' have any sort or filter in the form. As I show before the SELECT statement has a ORDER BY and yes the order is respected when the form loads, the only thing is that the record that shows when the form is opened is the second one and the first one. I review the forums yes but at least the ones I tale a look was on how to use a SORT or how to after save show the records sorted again. I will review again, maybe as you said is the CurrentIndex... that goes to the second record and I don't know why? regards
Everything is possible, just keep trying...
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
I promise that this is your problem. If you put a break point you will see that the data behind the CurrentRowIndex is changed....the ONLY way that this will happen is through a filter or a sort or manually changing the data table and/or view. You are welcome to post a sample, but I have seen this too many times in the past and I am confident that is your issue.
|
|
|
Juan Carlos Pazos
|
|
Group: Forum Members
Posts: 144,
Visits: 227
|
Hi Just found the solution: Private Sub FamiliasBO1_ParentFormLoading() Handles FamiliasBO1.ParentFormLoading '-- Load BO Me.FamiliasBO1.FillTodos() '-- Go to first record FamiliasBO1.Navigate(MicroFour.StrataFrame.Business.BusinessNavigationDirection.First) End Sub As the FillTodos is already sorted, I only need to go to the first record. Without that the BO loads ordered but shows the first record in the primary index. Navigate to the first record puts the form just as I need. Thanks all for your help.
Everything is possible, just keep trying...
|
|
|
Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
Hi Juan Carlos, Try putting the Navigate() command in the BO.FillTodos(), that way you keep the code related to the BO in the BO in case you need to call BO.FillTodos() from another place and want to have the records properly sorted.
Edhy Rijo
|
|
|
Randy Jean
|
|
Group: StrataFrame Users
Posts: 105,
Visits: 641
|
This is a re-producible issue that I showed Ben on the last day of training in Amarillo using sample app business objects and he confirmed it definitely was not a filter/sort issue with what I showed him, but immediately after the filldatatable, the currentrowindex was set to the 2nd record (or actually a 1 vs. a 0). Sure, putting a navigate in the fill method should rectify the issue, but still curious as to what's actually causing this to happen. I had been meaning to follow-up with Ben but been real busy with some other projects and just getting back to some Strataframe work myself. This has bitten us a few times but we've managed to just work around it for now.
|
|
|
Randy Jean
|
|
Group: StrataFrame Users
Posts: 105,
Visits: 641
|
Actually, a movefirst is what we want instead of navigate, I believe. Navigate tries to update bound controls so don't think that's needed if doing this inside the fill itself.
|
|
|
Dustin Taylor
|
|
Group: StrataFrame Users
Posts: 364,
Visits: 771
|
Trent was looking at the code behind this the other day, and the CurrentIndex is indeed getting set right after the filldatatable, so I'm not sure how that could be an issue. However, if it is reproducable, could you post that sample up as an attatchment so we can take a look at it. Ben didn't mention anything to me about it, so he may have already addressed this (he's on vacation at the moment, so I can't just go ask him ). Regardless, a sample that uses the StrataFrame Sample info and fails on your end will tell us for sure.
|
|
|
Randy Jean
|
|
Group: StrataFrame Users
Posts: 105,
Visits: 641
|
In the CRM sample app, add a FillAll method to the customer BO (without a movefirst after the filldatatable):
Public Sub FillAll()
Dim loCommand As New SqlCommand()
'-- Create the command
loCommand.CommandText = "SELECT * FROM Customers Order By Cust_Company"
'-- Execute the command
Me.FillDataTable(loCommand)
End Sub
Then, in the customer maintenance form load, call the new fillall method:
Private Sub CustomerMaintenance_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Customers.FillAll()
End Sub
In my case, when I run the form, I can click the "back" button on the binding navigator and there is indeed a record that it skips back to - but it should actually not be able to skip back if it is indeed on the first record. If this doesn't happen to you, then I'm not sure what could be different. It does this on every business object we have and we're not setting any sorts for filters of any kind. Also running the latest SF beta of 1.6.6 I believe. Thanks, Randy
|
|
|