Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Some Grid Bugs... I think
Message
From
02/01/2001 19:09:07
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Some Grid Bugs... I think
Miscellaneous
Thread ID:
00458706
Message ID:
00458706
Views:
55
Hey everyone,

Has anyone hit these PITAs?

Here's the first chunk of code. WHen its run, it will move the record pointer of the select alias to EOF in the line between the WAIT WINDOWs. THe work around is marked by "***", take them out and you should be fine.
****************************************************
* EXAMPLE1

close data all

* This is the form we will use
oForm = createobject('form')

* Create the Utility table, the main table, and the main tables group table
create table Utility (ID_Utility i)
append blank

create table Main (ID_Main i, ID_Group i)
for lnI = 1 to 20
	append blank
	replace ID_Main with lnI, ID_Group with mod(lnI, 2) + 1
endfor

create table Group (ID_Group i)
for lnI = 1 to 2
	append blank
	replace ID_Group with lnI
endfor
index on ID_Group to group.idx
set relation to ID_Group into group in main

select 1

*** *This is the work around, go to another Work Area
*** select 2

* Now build add a grid an build columns
oForm.AddObject('oGrid', 'grid')
oForm.oGrid.Visible = .T.
oForm.oGrid.ColumnCount = 0
oForm.oGrid.RecordSource = 'main'
oForm.oGrid.AddColumn()
oForm.oGrid.Column1.ControlSource = 'main.id_main'
oForm.oGrid.AddColumn()
wait window tran(recno('utility'))
oForm.oGrid.Column2.ControlSource = 'group.id_group'
wait window tran(recno('utility'))

*** *Now go back
*** select 1

oForm.Show(1)
In the next code, when clicking on the header the record pointer moves here too. It moves strangly though, say you are on the second displayed item, the order will be reversed, and the record that used to be above the first item is now the selected item. If the third visible record is the current record in the grid, when the order is reversed the record two above the first record will become the current one. If you watch, the top record always stays on top, so if the top record is current, when the order is flipped it will remain current. If you're not lost by this point, isn't that wierd?
****************************************************
* EXAMPLE2

* Create sample data
CREATE TABLE sorttest (field1 c(2))
FOR lnI = 1 TO 20
	APPEND BLANK 
	replace field1 with TRANSFORM(lnI)
ENDFOR 
INDEX ON field1 TAG field1 OF sorttest.cdx
GO TOP 

* Create a form with a grid
oForm=CREATEOBJECT("form")
oForm.AddObject('oGrid', 'grid')

* Setup a column for the Sorttest field
oForm.oGrid.RecordSource = 'sorttest'
oForm.oGrid.ColumnCount = 1
oForm.oGrid.Column1.ControlSource = 'sorttest.field1'

* Remove the standard header and add our funcitonal one
oForm.oGrid.Column1.RemoveObject('Header1')
oForm.oGrid.Column1.AddObject('Header1', 'myheader')

* Show our objects
oForm.oGrid.Visible = .T.
oForm.Show(1)

CLOSE DATABASES all 

DEFINE CLASS MyHeader AS header

	PROCEDURE Click
		lcAlias = 'sorttest'
		lcTag   = 'FIELD1'

		lnSelect = select()
		select (lcAlias)

		do case

			* If we were never sorted or are descending, go ascending
			case order() <> lcTag
				set order to (lcTag) ascending

			case 'DESCENDING' $ set('ORDER')
				set order to (lcTag) ascending

			* Otherwise we are all ready sorted ascending, make it descending
			otherwise
				set order to (lcTag) descending
		endcase

		*** *Here's the work around for this one
		*** lnRecno = recno()
		thisform.Refresh()
		*** go (lnrecno)

		* Reset stuff
		select (lnSelect)
	ENDPROC
ENDDEFINE
Next
Reply
Map
View

Click here to load this message in the networking platform