Hello!

Hello!

I am having an attack of stupidity and can't figure out where I am going wrong.
This is my dataset ( TFDMemTable ):

object tblJobs: TFDMemTable
OnCalcFields = tblJobsCalcFields
FieldDefs = <>
IndexDefs = <>
FetchOptions.AssignedValues = [evMode]
FetchOptions.Mode = fmAll
ResourceOptions.AssignedValues = [rvPersistent, rvSilentMode]
ResourceOptions.Persistent = True
ResourceOptions.SilentMode = True
UpdateOptions.AssignedValues = [uvCheckRequired, uvAutoCommitUpdates]
UpdateOptions.CheckRequired = False
UpdateOptions.AutoCommitUpdates = True
StoreDefs = True
Left = 408
Top = 152
object tblJobsID: TAutoIncField
FieldName = 'ID'
Visible = False
end
object tblJobsCOMPANY_ID: TIntegerField
FieldName = 'COMPANY_ID'
Visible = False
end
object tblJobsREFERENCE: TWideStringField
DisplayLabel = 'Ref#'
FieldName = 'REFERENCE'
Size = 255
end
object tblJobsTITLE: TWideStringField
DisplayLabel = 'Job'
FieldName = 'TITLE'
Size = 255
end
object tblJobsCOMPANY_NAME: TWideStringField
DisplayLabel = 'Company'
FieldKind = fkLookup
FieldName = 'COMPANY_NAME'
LookupDataSet = tblCompanies
LookupKeyFields = 'ID'
LookupResultField = 'NAME'
KeyFields = 'COMPANY_ID'
Size = 255
Lookup = True
end
object tblJobsSIGNED_OFF: TBooleanField
DisplayLabel = 'Signed off'
FieldName = 'SIGNED_OFF'
end
object tblJobsJOBTYPE: TWideStringField
FieldKind = fkLookup
FieldName = 'JOBTYPE'
LookupDataSet = tblJobType
LookupKeyFields = 'ID'
LookupResultField = 'TYPE_NAME'
KeyFields = 'JOB_TYPE_ID'
Size = 255
Lookup = True
end
object tblJobsJOB_DESCRIPTION: TWideStringField
FieldKind = fkCalculated
FieldName = 'JOB_DESCRIPTION'
Size = 255
Calculated = True
end
object tblJobsJOB_TYPE_ID: TIntegerField
FieldName = 'JOB_TYPE_ID'
end
end

There are two lookups: JOBTYPE and COMPANY_NAME.

I am using a cxGrid but the lookups don't work properly.
Here is how the company one is defined:

object grdJobsDBTableViewCOMPANY_NAME: TcxGridDBColumn
DataBinding.FieldName = 'COMPANY_NAME'
Width = 150
end

There's not much here, so it should just work because everything else is default.

Has this ever happened to you? Would you know what's going on?

Thanks!

Comments

  1. If i remember correctly, the cxGrid has it's own Lookup controls.

    When working with lookups that has multiple fields in the LookupKeyFields (something like "TYPE;VERSION") the TDataSet based lookup must be used. Those fields will come at the top when you create the fields dynamically (or in the IDE).

    In either case (also from memory, not 100%) you need to drop a DX lookup component on the grid and connect it properly to the field(s). Did you try that /even though/ you are using the TDataSet lookup functionality?

    If that Query is taken right off i would suspect you get the "looked up" text in the grid. But if you want to have an actual lookup, you should connect a lookup DB-aware editor to the index field and the properties of that lookup to the lookup dataset and specify it's fields.

    Mind sorting and filtering, it will work differently in different approaches.

    HTH, come back otherwise and i'll check in my dev-machine.

    ReplyDelete
  2. Hi Andrea Raimondi what the behaviour your are experiencing? Empty fields? An Av exception? Can you share a sample.project?

    ReplyDelete
  3. Francisco Armando Dueñas Rodríguez, quite simply, if I changed the selection, it wouldn't budge and change it, but instead revert to the one I was moving away from. However, deleting the data files and regenerating them seems to have done the trick. Very strange.

    ReplyDelete
  4. Oh yes, naturally, first thing I do because of past... ahem... "episodes"....

    ReplyDelete
  5. Also as a rule of thumb. In a tdataset, in the fieldlist: Datafields should go first and calc and lookup fields at the ends of the fieldlist

    ReplyDelete

Post a Comment