DALookupFieldDefinition

Overview

DALookupFieldDefinition is a specialization of the general DAFieldDefinition class, and represents a field for which the value is not stored directly in the DADataTable but looked up from a secondary table via a reference source field The source field is another field defined in the same table as the lookup field, and its value will be matched against a lookup key field in the secondary table, to obtain the referenced row. The lookup result field from the secondary table will be used as resulting value.

Lookup fields are often used with tables from a relational database containing Foreign Key. For example, an "Orders" table might have references to a customers via a "CustomerID" field (this field is called the foreign key). The values in "CustomerID" will match values of the Primary Key in a "Customers" table (say, called "ID"). A lookup field could then be configured to follow this relation, obtain the "CustomerName" field and make it available locally within the "Orders" DADataTable.

DALookupFieldDefinitions can be created either by calling addLookupFieldName:sourceField:lookupTable:lookupKeyField:lookupResultField: on the DADataTable with the setup details, or by manually creating an instance and passing it to addLookupField:.

Lookup fields can be seen in action in the Field Types sample.

Location

 

dataType    (declared in DAFieldDefinition)

Specifies the Data Type for the field.

@property (readonly) enum DADataType dataType

dataTypeName    (declared in DAFieldDefinition)

Returns the readable name of the fields data type, as defined by the dataType property.

@property (readonly) NSString *dataTypeName

initWithDataTable:name:sourceField:lookupTable:lookupKeyField:lookupResultField:

Initializes new instance of the DALookupFieldDefinition

- (id) initWithDataTable:(DADataTable *)ownerTable name:(NSString *)fieldName sourceField:(DAFieldDefinition *)sourceField lookupTable:(DADataTable *)lookupTable lookupKeyField:(DAFieldDefinition *)lookupKeyField lookupResultField:(DAFieldDefinition *)lookupResultField

Parameters:

  • ownerTable: DADataTable instance to which this lookup field definition belongs
  • fieldName: Name of the lookup field
  • sourceField: Instance of the field definition that contains key values.
  • lookupTable: Instance of the lookup table (usually its a reference which holds descriptions for lookup keys)
  • lookupKeyField: Field definition in the Lookup table which has key values
  • lookupResultField: Field definition in the Lookup table which has result text values

initWithTable:    (declared in DAFieldDefinition)

Initializes new DAFieldDefinition instance with given data table

- (id) initWithTable:(DADataTable *)ownerTable

Parameters:


initWithTable:name:    (declared in DAFieldDefinition)

Initializes a new DAFieldDefinition instance with given data table and field name.

- (id) initWithTable:(DADataTable *)ownerTable name:(NSString *)fieldName

Parameters:

  • ownerTable:
  • fieldName:

lookupIndex

Mainly for internal use, this property exposes the DAIndex that will be used internally to perform the lookups. The DALookupFieldDefinition caches this index, for performance reasons.

@property (readonly) DAIndex *lookupIndex

lookupKeyField

References the key field field in the lookupTable. This is the field that will be used to locate the appropriate row in the lookup table matching the sourceField value.

@property (readonly) DAFieldDefinition *lookupKeyField

lookupResultField

References the result field field in the lookupTable. This is the field that will provide the value for the lookup field, once a row in the lookup table has been located.

@property (readonly) DAFieldDefinition *lookupResultField

lookupTable

References the table that will be used to look up values for this lookup field.

@property (readonly) DADataTable *lookupTable

name    (declared in DAFieldDefinition)

Specifies the uniqe name of the field within the data table. The field can be queried by this name using KVC's valueForKey: and setValue:forKey: methods on the individual DADataTableRows.

@property (readonly) NSString *name

position    (declared in DAFieldDefinition)

Returns the position or index of the field within the data table. This is mainly for internal use; regular field access should use the name and not rely on position.

@property (readonly) NSInteger position

predicateEditorRowTemplates    (declared in DAFieldDefinition)

Returns an array with one or more NSPredicateEditorRowTemplates that match the field definition, for use in an NSPredicateEditor. Usually, you will not call 'send this message' to an individual field, but use the DADataTable's defaultPredicateEditorRowTemplates method. See also Working with NSPredicateEditor (Xcode (Mac)).

- (NSArray *) predicateEditorRowTemplates

properties    (declared in DAFieldDefinition)

Provides access to various properties of the field as defined in the server's Schema.

@property (readonly) NSDictionary *properties

setProperty:toValue:    (declared in DAFieldDefinition)

Updates a property stored in the properties list.

- (void) setProperty:(NSString *)propertyName toValue:(NSString *)propertyValue

Parameters:

  • propertyName: name of the property for which we want to set new value
  • propertyValue: new value we want to set.

sourceField

References the source field field in the same table that contains this DALookupFieldDefinition. This is the field that will provide the original value that will be used to locate the appropriate row in the lookup table.

@property (readonly) DAFieldDefinition *sourceField

table    (declared in DAFieldDefinition)

Returns a reference to the DADataTable that contains this field.

@property (readonly) DADataTable *table

valueForRow:

Obtains and returns the lookup value for the specified row.

- (id) valueForRow:(DADataTableRow *)row

Parameters:

  • row: Row instance

visible  assign    (declared in DAFieldDefinition)

Specifies whether this field should be visible in user interfaces. This property is not used directly by the Data Abstract framework, but can be queried by user interface code to determine whether to see the field (for example in a table view or a field picker) or not. visible will be initialized based on the value set in the Schema, server-side, but can be changed within the client, if necessary.

@property (assign) BOOL visible

 

dataType    (declared in DAFieldDefinition)

Specifies the Data Type for the field.

@property (readonly) enum DADataType dataType

dataTypeName    (declared in DAFieldDefinition)

Returns the readable name of the fields data type, as defined by the dataType property.

@property (readonly) NSString *dataTypeName

lookupIndex

Mainly for internal use, this property exposes the DAIndex that will be used internally to perform the lookups. The DALookupFieldDefinition caches this index, for performance reasons.

@property (readonly) DAIndex *lookupIndex

lookupKeyField

References the key field field in the lookupTable. This is the field that will be used to locate the appropriate row in the lookup table matching the sourceField value.

@property (readonly) DAFieldDefinition *lookupKeyField

lookupResultField

References the result field field in the lookupTable. This is the field that will provide the value for the lookup field, once a row in the lookup table has been located.

@property (readonly) DAFieldDefinition *lookupResultField

lookupTable

References the table that will be used to look up values for this lookup field.

@property (readonly) DADataTable *lookupTable

name    (declared in DAFieldDefinition)

Specifies the uniqe name of the field within the data table. The field can be queried by this name using KVC's valueForKey: and setValue:forKey: methods on the individual DADataTableRows.

@property (readonly) NSString *name

position    (declared in DAFieldDefinition)

Returns the position or index of the field within the data table. This is mainly for internal use; regular field access should use the name and not rely on position.

@property (readonly) NSInteger position

properties    (declared in DAFieldDefinition)

Provides access to various properties of the field as defined in the server's Schema.

@property (readonly) NSDictionary *properties

sourceField

References the source field field in the same table that contains this DALookupFieldDefinition. This is the field that will provide the original value that will be used to locate the appropriate row in the lookup table.

@property (readonly) DAFieldDefinition *sourceField

table    (declared in DAFieldDefinition)

Returns a reference to the DADataTable that contains this field.

@property (readonly) DADataTable *table

visible  assign    (declared in DAFieldDefinition)

Specifies whether this field should be visible in user interfaces. This property is not used directly by the Data Abstract framework, but can be queried by user interface code to determine whether to see the field (for example in a table view or a field picker) or not. visible will be initialized based on the value set in the Schema, server-side, but can be changed within the client, if necessary.

@property (assign) BOOL visible

 

initWithDataTable:name:sourceField:lookupTable:lookupKeyField:lookupResultField:

Initializes new instance of the DALookupFieldDefinition

- (id) initWithDataTable:(DADataTable *)ownerTable name:(NSString *)fieldName sourceField:(DAFieldDefinition *)sourceField lookupTable:(DADataTable *)lookupTable lookupKeyField:(DAFieldDefinition *)lookupKeyField lookupResultField:(DAFieldDefinition *)lookupResultField

Parameters:

  • ownerTable: DADataTable instance to which this lookup field definition belongs
  • fieldName: Name of the lookup field
  • sourceField: Instance of the field definition that contains key values.
  • lookupTable: Instance of the lookup table (usually its a reference which holds descriptions for lookup keys)
  • lookupKeyField: Field definition in the Lookup table which has key values
  • lookupResultField: Field definition in the Lookup table which has result text values

initWithTable:    (declared in DAFieldDefinition)

Initializes new DAFieldDefinition instance with given data table

- (id) initWithTable:(DADataTable *)ownerTable

Parameters:


initWithTable:name:    (declared in DAFieldDefinition)

Initializes a new DAFieldDefinition instance with given data table and field name.

- (id) initWithTable:(DADataTable *)ownerTable name:(NSString *)fieldName

Parameters:

  • ownerTable:
  • fieldName:

predicateEditorRowTemplates    (declared in DAFieldDefinition)

Returns an array with one or more NSPredicateEditorRowTemplates that match the field definition, for use in an NSPredicateEditor. Usually, you will not call 'send this message' to an individual field, but use the DADataTable's defaultPredicateEditorRowTemplates method. See also Working with NSPredicateEditor (Xcode (Mac)).

- (NSArray *) predicateEditorRowTemplates

setProperty:toValue:    (declared in DAFieldDefinition)

Updates a property stored in the properties list.

- (void) setProperty:(NSString *)propertyName toValue:(NSString *)propertyValue

Parameters:

  • propertyName: name of the property for which we want to set new value
  • propertyValue: new value we want to set.

valueForRow:

Obtains and returns the lookup value for the specified row.

- (id) valueForRow:(DADataTableRow *)row

Parameters:

  • row: Row instance

See Also