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
- Reference: DALookupFieldDefinition.h
- Namespace: DataAbstract
- Ancestry: NSObject | DAFieldDefinition | DALookupFieldDefinition
attributeType (declared in DAFieldDefinition)
- (NSAttributeType) attributeType
autoIncrement (declared in DAFieldDefinition)
- (BOOL) autoIncrement
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:
- (InstanceType) initWithDataTable:(DADataTable *)ownerTable name:(NSString *)fieldName sourceField:(DAFieldDefinition *)sourceField lookupTable:(DADataTable *)lookupTable lookupKeyField:(DAFieldDefinition *)lookupKeyField lookupResultField:(DAFieldDefinition *)lookupResultField
Parameters:
- ownerTable:
- fieldName:
- sourceField:
- lookupTable:
- lookupKeyField:
- lookupResultField:
initWithTable: (declared in DAFieldDefinition)
- (InstanceType) initWithTable:(DADataTable *)ownerTable
Parameters:
- ownerTable:
initWithTable:andSchema: (declared in DAFieldDefinition)
- (InstanceType) initWithTable:(DADataTable *)ownerTable andSchema:(DASchemaDataTableField *)schemaField
Parameters:
- ownerTable:
- schemaField:
initWithTable:name: (declared in DAFieldDefinition)
- (InstanceType) 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
predicateEditorRowTemplateForName:type: (declared in DAFieldDefinition)
+ (NSPredicateEditorRowTemplate *) predicateEditorRowTemplateForName:(NSString *)name type:(NSAttributeType)type
Parameters:
- name:
- type:
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).
- (NSArray *) predicateEditorRowTemplates
predicateEditorRowTemplateStandardOperators (declared in DAFieldDefinition)
+ (NSArray *) predicateEditorRowTemplateStandardOperators
properties (declared in DAFieldDefinition)
Provides access to various properties of the field as defined in the server's Schema.
@property (readonly) NSDictionary *properties
setDataType: (declared in DAFieldDefinition)
- (void) setDataType:(enum DADataType)aType
Parameters:
- aType:
setPosition: (declared in DAFieldDefinition)
- (void) setPosition:(NSInteger)aPosition
Parameters:
- aPosition:
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
predicateEditorRowTemplateForName:type: (declared in DAFieldDefinition)
+ (NSPredicateEditorRowTemplate *) predicateEditorRowTemplateForName:(NSString *)name type:(NSAttributeType)type
Parameters:
- name:
- type:
predicateEditorRowTemplateStandardOperators (declared in DAFieldDefinition)
+ (NSArray *) predicateEditorRowTemplateStandardOperators
attributeType (declared in DAFieldDefinition)
- (NSAttributeType) attributeType
autoIncrement (declared in DAFieldDefinition)
- (BOOL) autoIncrement
initWithDataTable:name:sourceField:lookupTable:lookupKeyField:lookupResultField:
- (InstanceType) initWithDataTable:(DADataTable *)ownerTable name:(NSString *)fieldName sourceField:(DAFieldDefinition *)sourceField lookupTable:(DADataTable *)lookupTable lookupKeyField:(DAFieldDefinition *)lookupKeyField lookupResultField:(DAFieldDefinition *)lookupResultField
Parameters:
- ownerTable:
- fieldName:
- sourceField:
- lookupTable:
- lookupKeyField:
- lookupResultField:
initWithTable: (declared in DAFieldDefinition)
- (InstanceType) initWithTable:(DADataTable *)ownerTable
Parameters:
- ownerTable:
initWithTable:andSchema: (declared in DAFieldDefinition)
- (InstanceType) initWithTable:(DADataTable *)ownerTable andSchema:(DASchemaDataTableField *)schemaField
Parameters:
- ownerTable:
- schemaField:
initWithTable:name: (declared in DAFieldDefinition)
- (InstanceType) 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).
- (NSArray *) predicateEditorRowTemplates
setDataType: (declared in DAFieldDefinition)
- (void) setDataType:(enum DADataType)aType
Parameters:
- aType:
setPosition: (declared in DAFieldDefinition)
- (void) setPosition:(NSInteger)aPosition
Parameters:
- aPosition:
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
- Field Types sample
- DACalculatedFieldDefinition class