grid problem  
Author Message
collide





PostPosted: Visual FoxPro General, grid problem Top

hi guys...im working on my thesis and its a library system...i have two grids in the form, the first grid are the list of books and the second grid contains the other copies of the book selected on the first grid...what i want to happen is that when the second grid shows the other copies of the book, i want to distinguish whether the book is available or unavailable by changing its forecolor to a different color...how will i be able to change its color if its available im using an SQL statement to fill in the second grid..should i include in the SQL the column where the you'll know whether its available or unavailable please help me guys...thanks :)


Visual FoxPro2  
 
 
CetinBasoz





PostPosted: Visual FoxPro General, grid problem Top

Generally it is better to calculate availability before you show the grids (you'd do the needed SQL once). However it can be done per movement in first grid too (thinking a library's items capacity is much less than VFP's high speed queries you might do this though an unoptimized way).

One way or the other you'd have something to change color based on.

* Grid.init

this.SetAll("DynamicBackColor", "(thisform.CheckAvailability(myLlibTable.itemid))")

* Form.CheckAvailability
lparameters tuItemId
* check availability code and store result to say IsAvailable
return iif( m.IsAvailable, 0x00FF00, 0xC0C0C0 ) && return green or gray based on result

PS: Do not try doing this with generally suggested SetAll( "DynamicBackColor", "iif(...)" ) way. It might quickly turn to be unmanagable as your expression gets complex.

Here is some code that would be optimized:

* from.init
this.Addproperty("aAvailable[1]")
select itemid from myLibTable pt ;
inner join myLibCopies ct on pt.itemid = ct.itemid ;
where ct.atLibrary ;
into array this.aAvailable

*

* Form.CheckAvailability
lparameters tuItemId
local IsAvailable
IsAvailable = ( ascan(this.aAvailable,m.tuItemId,1,-1,1+2+4) > 0 )
return iif( m.IsAvailable, 0x00FF00, 0xC0C0C0 ) && return green or gray based on result