Subject | Re: [IBO] How add calculated fields at R/T w/ default fields?? |
---|---|
Author | G. Allen Casteran |
Post date | 2001-11-03T02:06:25Z |
Helen,
Thanks for the info... More points below.
At 12:55 PM 11/3/2001 +1100, you wrote:
<snip>
FieldByName() the field IS found, but it's Index is -1. InfoPower uses the
Field.Index to map the field to their grid control. That is one reason I
need to have the Index set to a valid value.
is all created in code. Except for this one snafu, it all works great.
Allen.
Thanks for the info... More points below.
At 12:55 PM 11/3/2001 +1100, you wrote:
<snip>
> >Here is what I have tried:Good point, I'll look into this.
> >
> >//TPaymentsData is an TIBODataset descendant, which is a TDataset
> >descendant
> >procedure TPaymentsData.DoAfterOpen;
>
>I'm sure that you could not add a new object to the dataset after the
>dataset is open. At the latest, I would think (if you could do it at all)
>it would have to be (a) before Prepare and (b) while the dataset is in an
>unprepared state.
> > varThe Fields.Count is getting the correct value. Later when doing a
> > Fld : TField;
> > begin
> > // Add WHCode calcd field
> > Fld := TField.Create(Self);
> > Fld.FieldKind := fkCalculated;
> > Fld.FieldName := 'WHCodeCalc';
> > Fld.Calculated := True;
> > Fld.Index := Fields.Count; // <-- problem: does not set, stays at
> >-1 ??
>
>Fields.Count won't be available if the dataset isn't prepared. If it is
>returning -1 in the AfterOpen event then it looks as if your dataset isn't
>even prepared, let alone open.
FieldByName() the field IS found, but it's Index is -1. InfoPower uses the
Field.Index to map the field to their grid control. That is one reason I
need to have the Index set to a valid value.
>Also, I notice that you haven't assigned a FieldType to the calculatedAnother good point! This goes in the Homer Simpson category.... DOH!!!
>field and you also haven't subclassed TField to the descendant you
>want. TField is an abstract base class so you must do this.
>As I said, I don't know whether TDataset lets you add to the Fields[]The dataset object is created as part of a business object framework. This
>array at runtime *at all*. What requirement do you have that prevents you
>from creating the calculated field at design time?
is all created in code. Except for this one snafu, it all works great.
Allen.