StrataFrame Forum

seek-problem

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

By Thomas Holste - 8/16/2012

Hi there,

in a form I want to use as a lookup-form I have a problem with the seek-method, which does not seem to work.

On the form, the BO "LieferöookupBO' is filled in the parentformloading-event.

The calling form, which activates the lookup-form, send a search-parameter, which is

assigned to a private form-var. In the Load-Event I tried my seek-implementation:



If cSuche.Length > 0 Then

Dim lRet As Boolean

MsgBox("Count: " & LieferBO1.Count.ToString)  ' Just testing, if the BO is filled. It is.

lRet = LieferLookupBo.Seek(
"adresse='CLA'")   ' Hardcoded just fpr testing purposes.

If lRet Then

MsgBox("Found: " & LieferBO1.ADRESSE) ' Has not moved the current row index, not showing "CLA"

Else

MsgBox("Nothing")

End If



The search happens on a table containing lookup-codes like:

ASAP

AVA

BM

CLA

Now what happens is, that seek returns True, as if if has found "CLA" but the current row index has not changed (as described in the help-file) as the "ADRESSE"-property of the BO is showing the first code in the table "ASAP".

Can anybody tell me. what is going wrong there.

Best regards

Thomas
By Trent L. Taylor - 8/16/2012

There is something else in your form moving the row back to another position.

Try this.  Instead of doing all of this in a form load.  Override the OnLoad event of the form.  This is safer anyway.  You can still call the base logic, then place your coder after the base code.  At this point, most of the core logic will have been executed.  Another option, is to just create a button on the form, temporarily, that executes your code.  This will prove is something else is moving the row pointer as part of a load-up process.

It seems like there is a navigate going on elsewhere that is positioning the record.  This could happen if you are placing this code to early in the load (prior to core form logic) and there is data binding in place that is binding to the same BO instance that you are working with.

A seek doesn't update the binding where a navigate does.  Also, be sure to check your code to make sure that there isn't something else in your form that accesses the same instance of the BO and moves the record pointer.

Just FYI, the seek is a very straight forward process, so move your code downstream on the loading sequence to see if you can get the results that you are looking for and then you can work backwards from there.
By Edhy Rijo - 8/16/2012

Hi Thomas,

Also, be aware that when you are using a ChildFormDialog, you can take full advantage of the BO Translations, so in your Parent Form, since you know what is your Lookup Code to search for, then do the search in the Parent form and make sure the "LieferöookupBO" CurrentRowIndex is the expected one.

Now back to your original situation, as Trent said, something is moving the record of that BO after the seek, be aware of any BO.Filter or BO.Sort conditions since these will alter the way the BO is navigated and alter the expected result.
By Trent L. Taylor - 8/16/2012

Thomas:

Be sure to use the BO translations for the child form and use the ChildFormDialog.  This is a MUST really when using child forms as it will save you days of coding since it translates the BOs.  But you MUST...repeat...MUST place you code in the OnLoad (overrride this in the child form) AFTER the base code is called.  All of the translation wiring is in the base class of the load, so if you place your code first, then you could very well have some of the behavior you are talking about.

http://forum.strataframe.net/Uploads/Images/2c47bec8-8a3d-4f86-820c-b1fa.png
By Thomas Holste - 8/16/2012

Hi Trent,

thanks a lot for yout help. Executing the code in an Overridden Onload-Event did it, now almost everything works. The only thing I am still struggling with is to find out how to refresh the datagridview with which the BO is connected with a BusinessBindingSource.

The "record-pointer" of the BO is in the right position, which means, the searched row, but the currentrow of the grid is the first row in the BO. How can I synchronize this. I tried the grids refresh-method, but this does not work.

Best regards

Thomas
By Thomas Holste - 8/16/2012

Hi Edhy,

thanks for the idea of using a childformdialog, I will have a closer look at it.

Best regards

Thomas
By Edhy Rijo - 8/16/2012

Hi Thomas,

You are welcome!!!

Thomas Holste (8/16/2012)
The only thing I am still struggling with is to find out how to refresh the datagridview with which the BO is connected with a BusinessBindingSource


I know you are making an effort on this to work, but honestly the best way to handle a child form is using the ChildFormDialog and BO Translations.  About your DataGridView, the BusinessBindingSource should take care of synchronizing the CurrentRowIndex,  I use DevExpress grids, and that is the behavior I see, it could be something different with the DataGridView.
By Trent L. Taylor - 8/16/2012

The "record-pointer" of the BO is in the right position, which means, the searched row, but the currentrow of the grid is the first row in the BO. How can I synchronize this. I tried the grids refresh-method, but this does not work.


Remember that a Navigate actually refreshes the UI whereas the Seek doesn't.  So you may want to rework your code to try a Navigate and see if that gets you what you wanted.
By Thomas Holste - 8/16/2012

Hi Trent,

thanks a lot. Navigate makes it work like I want it.

Best regards

Thomas
By Thomas Holste - 8/16/2012

Hi Edhy,

I wonder if I have understood the conceot of the childformdialog. I use use them when I call forms to edit daa, which is presented on a parent form in some kind of "gridmode". The user selects a record and then edits it.

This lookup-form I am building right now is intended to be callend from many different places, so I thought the easiest and best way is to have it independent from the different forms from which is it called. The data which is used for lookup is not being used on the parent forms so I would have tio setup the BO on each parentform and establish the childformdialog.

Best regards

Thomas
By Trent L. Taylor - 8/17/2012

You can still call it from many different places.  There is a BO that you have on your child form that is bound to your controls.  When you use the ChildFormDialog, it "translates" the BO on your child form to the reference on the parent form.  So the form itself is encapsulated and the ChildFormDialog wires everything up in the Onload of the child form.

So you can still call this same form from many different places because when you call it, you still want to populate the child with the data from whatever parent form you are calling it from.
By Edhy Rijo - 8/17/2012

Hi Thomas,

Thomas Holste (8/17/2012)
I wonder if I have understood the conceot of the childformdialog. I use use them when I call forms to edit daa, which is presented on a parent form in some kind of "gridmode". The user selects a record and then edits it.


As Trent says
You can still call it from many different places.
.  As all SF controls, they have a specific purpose, but they are also design to be used in many scenarios, same with the Business Objects, ChildFormDialogs are awesome and flexible, you don't have to use it just to modify a single record, you can do whatever you want, ex: I have cases where I need to modify a child record from different parents in different forms and different child BO, so I do the following:
  1. Create a form form with a Themed Panel
  2. Drop an instance of each child BO, ex BO1, BO2, BO3
  3. Add a Panel Page per each child BO I want to modify and add my controls as usual.
  4. In the constructor create a parameter based on a public enumeration that will control which page to activate.
  5. Override the Onload as suggested by Trent and then set the PanelManager's ActivePage based on the enumeration value, also set the form's PrimaryBusinessObject to the BO you want to work with.
  6. In the Parent forms, add a ChildFormDialog, select your form and most important, create a translation for the child BO you will be using.  Add a parameter based on the public enumeration in step 4 and you are done!
Again, these are just steps from my mind, so they may not be all needed, but bottom line is to show you that with SF you can think out of the box and be very creative.  I do sort of the same thing with the ListView automations to handle the Add process and instead of showing a child form, I do other stuff.
By Thomas Holste - 8/22/2012

Hi Edhy,

thanks for your explanations. I dio something similar with some forms like my customer- or my article-editing-forms which can be called from different places and this is working fine. All these forms have in common that the tables used on the childform are alo used on the parent form and the childformdialog does the translation to the childform.

But in this special case which started the thread I don't use the lookup-data (supplier-codes) on the parent-forms which call the lookup-form, so I don't understand why I should there use a childformdialog when it is (now, following Trents advice) working?

Best regards

Thomas
By Edhy Rijo - 8/22/2012

Hi Thomas,

Thomas Holste (8/22/2012)
...so I don't understand why I should there use a childformdialog when it is (now, following Trents advice) working?

You don't have to use a ChildFormDialog in all situations.  I was simply explaining how I use it and I prefer to stick with the framework tools as much as I can for several reasons, one of them to keep the source code as standard as possible.  I have cases where I used the ChildFormDialog with no BO to do some process and simply return OK or Cancel, so that is the beauty of the ChildFormDialog that it will not lock you to use it for one purpose only.
By Thomas Holste - 8/22/2012

Hi Edhy,

<< have cases where I used the ChildFormDialog with no BO to do some process and simply return OK or Cancel, so that is the beauty of the ChildFormDialog that it will not lock you to use it for one purpose only. >>

Thanks for that nice idea.

Best regards

Thomas