Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid Problem 1

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
Boy, I feel as if I'm using FoxPro for the first time. I have two grids on the same Tab Page of a form. Both grids are tied to views. I have set up the relationship between the views as follows.
Code:
* Form Load code

USE TicketDetailView NODATA IN 0
=CURSORSETPROP("Buffering", 5, "TicketDetailView")

USE TicketTaxView NODATA IN 0
SELECT TicketTaxView
INDEX ON STR(TktDtlFK,8,0) + TaxID TAG Item_TaxID
SET ORDER TO Item_TaxID
=CURSORSETPROP("Buffering", 5, "TicketTaxView")

SELECT TicketDetailView
SET RELATION TO STR(TktDtlPK,8,0) INTO TicketTaxView
GO Top
The TicketDetailView contains a list of items and the TicketTaxView contains a list of possible taxes to apply to the item in the TicketDetailView. When first displayed the TicketTaxView only contains the taxes that have been applied, when the Edit button is clicked, all possible taxes are added to the TicketTaxView for each item in the TicketDetailView. This works just fine. The problem is when I double click one of the tax rows (not the first row) in the grid for the TicketTaxView, the record pointer jumps to the first record in the grid. This only happens the first time, after that everything is fine. Also if I click in the TicketDetailView and change the detail record pointer, it works fine. I’ve used grids a lot, but this one has me stumped. Probably something really easy I’m missing here.


Auguy
Sylvania/Toledo Ohio
 
There is code in there and it is calling a custom method on the form, but even when I comment out all but the following
Code:
StateFuelTaxRate = 0.000000
FedFuelTaxRate   = 0.000000
OtherFuelTaxRate = 0.000000

Replace TicketDetailView.StateRate WITH StateFuelTaxRate, ;
	TicketDetailView.FedRate WITH FedFuelTaxRate, ;
	TicketDetailView.OtherRate WITH OtherFuelTaxRate ;
In TicketDetailView
I still get the pointer moving. It seems like whenever I hit the TicketDetailView it resets the pointer. Still looking for the problem.

Auguy
Sylvania/Toledo Ohio
 
Well, you do a REPLACE on one record of the TicketDetailView with your REPLACE ... IN TicketDetailView. I assume without further testing this triggers the RELATION set from TicketDetailView to TicketTaxView. And that triggers to jump o the first record fullfilling that relation. So you have some kind of circular effect.

You might check out replacing the RELATION by using the grid properties of RelationalExpr, ChildORder and Linkmaster.


In your case the grid displaying TicketTaxView would have the ChildOrder set to the Item_TaxID index (like you now SET ORDER). The LinkMaster then us set to TicketDetailView (like your RELATION now starts in TicketDetailView as the master table and into TicketTaxView as the child table). And the RelationalExpr needs to be "STR(TktDtlPK,8,0)".

And that should then only take effect, if you click in the parent grid.

I don't use relations often, because even if you have encapsalted the data access in views or cursor adapters and can do so on the cursor level without breaking oop rules of the seperate layers, the concept of relations have never really satisfied me, I'd rather have the child grid display a parameterized view only selecting the child records of the current parent record, you can then requery in the AfterRowColChange event of the parent grid and that's reliably only querying the currently needed child records once and does not cause any side effects of row changes, etc.

Bye, Olaf.

 
Thanks Olaf, great suggestions as always.

Auguy
Sylvania/Toledo Ohio
 
OK, I've removed the set relation and modified the TicketTaxView grid with Olaf's suggestions. On a dbl-click in the TicketTaxView grid I'm trying to scan through the TicketTaxView and sum up some values, replace a few fields in the TicketDetailView and return to the currrent record in TicketTaxView. I've tries saving the record # and usign goto to return to the record, but this doesn;t work either. Any ideas on how to make this work?


Auguy
Sylvania/Toledo Ohio
 
Hold On, I think I have some other issues here, will post back with results.

Auguy
Sylvania/Toledo Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top