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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo in Grid issue 1

Status
Not open for further replies.

andre65

Programmer
Jan 19, 2003
95
NL
Hi all,

I have two combos in a Grid.
The first combo named cmbGroup contains data from a table called GROUP.
cmbGroup is bound to tablecolumn DATA.grp_nr
The second combo named cmbSubgroup contains data from a table called SUBGROUP.
cmbSubgroup is bound to tablecolumn DATA.sgp_nr

Table GROUP has fields NR, NAME
example: Cars, PC
Table SUBGROUP has fields NR, NAME, GRP_NR
example for group Cars: BMW, Mercedes
example for group PC:IBM, DELL, HP

I use for each combo .rowSourceType = 3 (=SQL statament)
cmbGroup.rowSource='select name,nr from group order by name'
cmbSubgroup.rowSource='select name,nr from subgroup where grp_nr=data.grp_nr order by name'

cmbGroup.interAciveChange: cmbSubgroup.requery()
So I see only those SUBGROUP which belongs to GROUP

Imagine there are 2 rows in the Grid
The first row contains GROUP=Cars, SUBGROUP=Mercedes
The second row contains GROUP=PC, SUBGROUP=DELL

The problem:
Navigating between the 2 rows will only show me the SUBGROUP for the focused row. The other row(s) will show me nothing. I think this is because dependency between GROUP and SUBGROUP.

The question:
How can I manage that cmbSubgroup will show me contents for all the rows.

Thanks for any reply.
André
 
Navigating between the 2 rows will only show me the SUBGROUP for the focused row. The other row(s) will show me nothing. I think this is because dependency between GROUP and SUBGROUP.

Columns Sparse property set to false?


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike:
I already have sparse=.t.
If I change this to sparse=.f., the column displays the number identified by DATA.sgp_id. This is in fact the correct subgroup value but I want to see the description of the corresponding SUBGROUP. Changing sparse to .t. will display nothing for some rows because the contents of cmbSubgroup depends on the selection of cmbGroup.

MarciaAkins:
It is a good code sample, but it does not describe my problem.

Some additional info:
Example, selected row is row1:
row1: cmbGroup displays Cars, cmbSubgroup displays Mercedes
row2: cmbSubgroup displays PC, cmbSubgroup displays NOTHING.

When moving to row2:
row1: cmbGroup displays Cars, cmbSubgroup displays NOTHING
row2: cmbSubgroup displays PC, cmbSubgroup displays Dell.

If I modify cmbSubgroup cursor rowsource to
[select name, nr from subgroup order by name] every row is displayed fine, but then cmbSubgroup contains all subgroups in the combolist instead of only the subgroups belonging to the selection in cmbGroup, so that is why I have the rowsource set to [select name, nr from subgroup where grp_id=data.grp_id order by name]

Who will help me solve this problem?

Thanks in advance.
Gr,
André
 

Navigating between the 2 rows will only show me the SUBGROUP for the focused row. The other row(s) will show me nothing. I think this is because dependency between GROUP and SUBGROUP.


If I understand correctly (based on the first post), you only see the correct information once you move the a row, and the row above (the one you just moved off of) no longer show you the correct information. Is that correct?

cmbGroup.interAciveChange: cmbSubgroup.requery()
If so, that would be the expected behavior since your combo requery() only requeries the row that has the focus.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike:

Your quote:
[If I understand correctly (based on the first post), you only see the correct information once you move the a row, and the row above (the one you just moved off of) no longer show you the correct information. Is that correct?]

My answer:
Yes, that is correct.


Your quote:
[If so, that would be the expected behavior since your combo requery() only requeries the row that has the focus]

My answer:
Yes, but what else should I do to fill cmbSubgroup from SUBGROUP with only those items which belongs to GROUP.
 
Hello Andre65

>> MarciaAkins:
It is a good code sample, but it does not describe my problem <<

Actually, one of the code samples does solve your problem. It is called ddlInGrid.scx. You are correct when you say that the problem is the dependent combo in the grid. So what you want to do on that grid column is:

1. Leave Sparse set at .T. (default)
2. Set the column's Bound Property to .F.
3. Set the column's controlSource to:

Code:
( IIF( SEEK( data.sgp_nr, [subgroup], [sgp_nr] ), subgroup.name, [] ) )

4. Make sure the text box in the grid column also has its ControlSource set to the expression above

5. Make sure that your combo has its style set to 2-Drop Down List and it is set up as you describe

6. Move the code that Requeries the combo from the InteractiveChange of the controling combo to the GotFocus of the dependent combo.






Marcia G. Akins
 
MarciaAtkins: Woooow, this works great!!

... I searched on your site and finally ended at FoxPro advisors for whicht I was not subscribed. I could only download one sample (which was also good).

Thanks a lot!

Gr,
André
 
Hello Andre.

>> I searched on your site and finally ended at FoxPro advisors for whicht I was not subscribed. I could only download one sample (which was also good). <<

This should not be. If you go to:


You should see a link to the "How to Put a Combo Box in a Grid" presentation that I gave at GLGDW in 2000. The downloadable zip has the white paper and all the code samples.




Marcia G. Akins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top