Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
UDF as control source for grid column
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00507675
Message ID:
00509476
Views:
21
>David,
>
>>>Yikes, I've asked this before; but how do I make one column in a grid, which is otherwise bound to a table show the value of a user defined function, eg grid.controlsource= myfunction(mytable.fieldname)
>I can't seem to make it work...>>
>
>
>Even if you do get it to work, its going to be *REALLY* slow (that UDF is firing for every cell on every refresh). Might I suggest you reference an object property (vs the UDF) which is updated by your UDF. That way the UDF is called only when some (legitimate) trigger event calls it, as opposed to being called dozens, hundreds, maybe thousands of times even though the result doesn't change.
>
>Regards,
>Thom C.

Thom,

Could you please elaborate more on your idea? I set up one of the column to be GetDesc(APNed,"APN"), where GetDesc is a program, include in a project and looks like this:
********************************************************************
*  Description.......: GetDesc
*  Calling Samples...: GetDesc(APNed,"APN")
*  Parameter List....: tcFieldVal, tcVarName
*  Created by........: Nadya Nosonovsky 04/03/2001 10:46:28 AM
*  Modified by.......: Nadya Nosonovsky 05/15/2001 03:30:34 PM
********************************************************************
lparameters tcFieldVal, tcVarName
if vartype(m.tcFieldVal)<>"C" or empty(m.tcFieldVal)
     return ""
endif

if vartype(m.tcVarName)<>"C" or empty(m.tcVarName)
     tcVarName="APN" && For tests only
else     
     tcVarName=upper(m.tcVarName)     
endif
#include mapreferrs.h
local lcReturn
lcReturn=''
do case
case m.tcFieldVal=TCCO_EDIT 
     lcReturn= TCMS_EDIT_SHORT
case m.tcVarName="APN"
     do case
     case m.tcFieldVal=APN_NOTDO
          lcReturn=APNMS_NOTDO_SHORT
     case m.tcFieldVal=APN_COMPL
          lcReturn=APNMS_COMPL_SHORT
     case m.tcFieldVal=APN_DUPL
          lcReturn=APNMS_DUPL_SHORT
     case m.tcFieldVal=APN_BAD
          lcReturn=APNMS_BAD_SHORT
     case m.tcFieldVal=APN_BAD
          lcReturn=APNMS_BAD_SHORT
     case m.tcFieldVal=APN_SUSPECT
          lcReturn=APNMS_SUSPECT_SHORT          
     endcase
case m.tcVarName="PARSE"
     do case
     case m.tcFieldVal=PARSE_NOTDO
          lcReturn=PARSEMS_NOTDO_SHORT
     case m.tcFieldVal=PARSE_COMPL
          lcReturn=PARSEMS_COMPL_SHORT
     case m.tcFieldVal=PARSE_DUPL
          lcReturn=PARSEMS_DUPL_SHORT
     case m.tcFieldVal=PARSE_BAD
          lcReturn=PARSEMS_BAD_SHORT
     endcase

case m.tcVarName="PARCEL"
     do case
     case m.tcFieldVal=PARCEL_NOTDO
          lcReturn=PARCELMS_NOTDO_SHORT
     case m.tcFieldVal=PARCEL_COMPL
          lcReturn=PARCELMS_COMPL_SHORT
     case m.tcFieldVal=PARCEL_DUPL
          lcReturn=PARCELMS_DUPL_SHORT
     case m.tcFieldVal=PARCEL_BAD
          lcReturn=PARCELMS_BAD_SHORT
     endcase

case m.tcVarName="MAPREF"
     do case
     case m.tcFieldVal=MAPREF_NOTDO
          lcReturn=MAPREFMS_NOTDO_SHORT
     case m.tcFieldVal=MAPREF_COMPL
          lcReturn=MAPREFMS_COMPL_SHORT
     case m.tcFieldVal=MAPREF_DUPL
          lcReturn=MAPREFMS_DUPL_SHORT
     case m.tcFieldVal=MAPREF_BAD
          lcReturn=MAPREFMS_BAD_SHORT     
     endcase
endcase

return m.lcReturn
I didn't notice significant delay on the tables with 25000 thousand records, but when I try to use scrollbar in the grid, it seems not responding properly, may be it's related. Basically, I want to show "Edited","Bad","Duplicate", etc., instead of "E","B","D". What would you suggest?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform