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!

Suppressing repeating values in grid

Status
Not open for further replies.

vanni75

Programmer
Nov 27, 2002
29
BE
Hi,

I have grid where i want that repeatinig values are only showed once.. And i want to work directly with the table so a view or cursor is not a solution.

Example..

BELGIUM JAN 10
KURT 20
GERD 15
FRANCE PIET 30
EGYPT ASAI 15
KINJO 30

anyone an idea how to do this..
 
If it's a single table then it's simply not possible using the VFP standard grid. If the first column was one table and there was a relationship into a table with the next two columns, then it could be done.

Rick
 
thx , can you tell me then how you do this with two tables?
 
The key is the SET SKIP command. I made a couple small modifications to an example in the Help file:
Code:
CLOSE DATABASES
* Creates parent table with values a and b in Name field
CREATE CURSOR Parent (Name C(1), Val C(10))
INSERT INTO Parent VALUES ('a', 'Parent.a1')
INSERT INTO Parent VALUES ('b', 'Parent.b1')

SELECT 0     && Child1 will have two a's and two b's
CREATE CURSOR Child1 (Name1 C(1), Val C(10))
INSERT INTO Child1 VALUES ('a', 'Child1.a1')
INSERT INTO Child1 VALUES ('b', 'Child1.b1')
INSERT INTO Child1 VALUES ('b', 'Child1.b2')
INSERT INTO Child1 VALUES ('a', 'Child1.a2')
INDEX ON Name1 TAG tagName   && The tag name is irrelevant

SELECT 0  && Child2 will have two a's and two b's
CREATE CURSOR Child2 (Name2 C(1), Val C(10))
INSERT INTO Child2 VALUES ('b', 'Child1.b1')
INSERT INTO Child2 VALUES ('b', 'Child1.b2')
INSERT INTO Child2 VALUES ('a', 'Child1.a1')
INSERT INTO Child2 VALUES ('a', 'Child1.a2')
INDEX ON Name2 TAG tagName     && The tag name is irrelevant

SELECT Child1
SET RELATION TO Name1 INTO Child2
SELECT Parent
SET RELATION TO Name INTO Child1
SET SKIP TO Child1, Child2 && Parent gets both skips.
           && Otherwise, only four record triplets 
           && would be listed.
*SELECT Parent
GO TOP
BROWSE FIELDS parent.val, child1.val:H="C1 Val", ;
  child2.val:H="C2 Val" nowait
Rick
 
Actually you can do this....

you can use a udf (bound as a control source) to skip backwards and determine if the field is the same...

Code:
FUNCTION MYGROUPFUNCTION
	PARAMETER MYFIELDNAME
	PRIVATE MYFIELDNAME,m.OLDRECNO,m.RETVAL
	M.RETVAL = &MYFIELDNAME
	M.OLDRECNO = RECNO()
	IF !BOF()
		SKIP -1
		IF !BOF()
			IF &MYFIELDNAME = m.RETVAL
				M.RETVAL = ""
			ENDIF
		ENDIF
	ENDIF
	IF m.OLDRECNO > 0 .AND. m.OLDRECNO <= RECCOUNT()
		GOTO m.OLDRECNO
	ENDIF
	RETURN(m.RETVAL)

HTH


Regards

Griff
Keep [Smile]ing
 
Griff,
Have you used this in a production app? What kind of impact does this have on the grid with thosands of records? With Multiple fields using this technique?

This of course does prevent the user from changing the data in this column.

Rick
 
Rick,

I've only used it on grids with one field implemented this way - but the speed is dependant on the size on the grid primarily (no of records in view) and the connection to the database (how fast it is).

It works well enough, and saves processing the table before viewing it.

HTH



Regards

Griff
Keep [Smile]ing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top