DADataTable

Overview

DADataTable is one of the core classes in Data Abstract, and used to represent the client version of an individual record set, or data table, that has been retrieved from the server.

A DADataTable contains an array of rows containing the actual data, and also maintains information about any changes that may have been made to these rows locally, but that have not yet been sent back to the server. Each row is represented by a DADataTableRow instance, and contains data as specified by a list of DAFieldDefinitions. Fields can either be real fields, for which the data is contained within the table itself, or Calculated and Lookup Fields, where the value is determined at runtime, when needed.

The individual rows in the table can be accessed as an NSArray of DADataTableRows using the rows property, or the overload rowsFilteredUsingPredicate:, rowsSortedByField:ascending: and rowsFilteredUsingPredicate:sortedByField:ascending: methods. The latter three return a copy of the list of rows matching the specific criteria.

The process of locating specific rows can be sped up using DAIndexes, which can be accessed using the indecForField: and related methods, and will maintain a pre-cached index that makes field lookups faster. Indexes are also used extensively internally in the Data Abstract, for example to implement Lookup Fields.

When working with an NSPredicateEditor to provide filtering options to the user (either for local filtering using rowsFilteredUsingPredicate: or for data retrieval using Dynamic Where), the defaultPredicateEditorRowTemplates method can be used to obtain a preconfigured list of NSPredicateEditorRowTemplates for the table (Mac only, as NSPredicateEditor is not available on the iPhone). See and the for more details on this.

Read more about the Data Tables at Remote Data Adapter and Data Tables (Xcode).

Tasks

Accessing and working with Rows

  • rowCount
  • rows
  • rowsFilteredUsingPredicate:
  • rowsFilteredUsingPredicate:sortedByField:ascending:
  • rowsSortedByField:ascending:
  • rowAtIndex:
  • addNewRow
  • removeRow:
  • removeRowAtIndex:

Accessing Fields

  • fieldCount
  • fields
  • fieldByName:
  • keyFields
  • loggedFields
  • realFields
  • addCalculatedField:
  • addCalculatedFieldName:dataType:target:selector:
  • addCalculatedFieldName:dataType:target:selector:cached:
  • addLookupField:
  • addLookupFieldName:sourceField:lookupTable:lookupKeyField:lookupResultField:

Changes

  • hasChanges
  • changedRows
  • cancelAllChanges
  • cancelChangesForRow:

Editing Mode

  • addNewRowInEditMode:
  • addNewRowWithDataFromDictionary:inEditMode:
  • postAll
  • discardAll

Indexes

  • indexForField:
  • buildIndexForField:
  • dropIndexForField:

Partitioning

*rowsPartitionedByField: *rowsPartitionedByField:includeNull:

Location

 

addCalculatedField:

Adds a new calculated field to the table. Please refer to the documentation for DACalculatedFieldDefinition for more details.

- (void) addCalculatedField:(DACalculatedFieldDefinition *)field

Parameters:


addCalculatedFieldName:dataType:target:selector:

Creates and adds a new calculated field to the table. Please refer to the documentation of DACalculatedFieldDefinition for more details.

- (DACalculatedFieldDefinition *) addCalculatedFieldName:(NSString *)name dataType:(enum DADataType)dataType target:(id)target selector:(SEL)selector

Parameters:

  • name: The unique name for the new calculated field.
  • dataType: The DADataType of the calculated field.
  • target: Reference to the object that will provide the method for calculating this field.
  • selector: Selector of method on the target that will calculate the field.

addCalculatedFieldName:dataType:target:selector:cached:

Adds a new usual or cached calculated field to the table. Please refer to the documentation for DACalculatedFieldDefinition for more details.

- (DACalculatedFieldDefinition *) addCalculatedFieldName:(NSString *)fieldName dataType:(enum DADataType)dataType target:(id)target selector:(SEL)selector cached:(BOOL)cached

Parameters:

  • fieldName: The unique name for the new calculated field.
  • dataType: The DADataType of the calculated field.
  • target: Reference to the object that will provide the method for calculating this field.
  • selector: Selector of method on the target that will calculate the field.
  • cached: Boolean flag. If YES then new cached calculated field will be added to the table. Please refer to the documentation for DACachedCalculatedFieldDefinition for more details.

addLookupField:

Adds lookup field definition to the table. Please refer to the documentation for DALookupFieldDefinition for more details.

- (void) addLookupField:(DALookupFieldDefinition *)field

Parameters:


addLookupFieldName:sourceField:lookupTable:lookupKeyField:lookupResultField:

Creates and appends a lookup field to the table. Please refer to the documentation for DALookupFieldDefinition for more details.

- (DALookupFieldDefinition *) addLookupFieldName:(NSString *)name sourceField:(DAFieldDefinition *)sourceField lookupTable:(DADataTable *)lookupTable lookupKeyField:(DAFieldDefinition *)lookupKeyField lookupResultField:(DAFieldDefinition *)lookupResultField

Parameters:

  • name: The unique name for the new calculated field.
  • sourceField: Initializes the sourceField property.
  • lookupTable: Initializes the lookupTable property.
  • lookupKeyField: Initializes the lookupKeyField property.
  • lookupResultField: Initializes the lookupResultField property.

addNewRow

Appends a new row to the table. If the row has any AutoInc columns, new negative ID values will be generated automatically for these. All other columns will be initialized as null. A reference to the newly added row will be returned to the caller.

This method triggers the 'TableChanged' notification for the DADataTable.

- (DADataTableRow *) addNewRow

addNewRowInEditMode:

Adds a new row for the table.

- (DADataTableRow *) addNewRowInEditMode:(BOOL)editMode

Parameters:

  • editMode: When YES then new row will be added in edit mode. Edit mode is different from the usual mode so that all changes are not visible for the table until they will be fixed by post method or cancelled by discard method.

addNewRowWithDataFromDictionary:inEditMode:

method which allows adding new row with the data from the dictionary in one go. If your table has an autoincrement key field then just omit passing its temporary value in the dictionary. It will be generated automatically by library (otherwize it will throw an exception saying that you cannot specify custom value for autoincrement field.) Also, you don’t need to pass values for ALL fields. You can specify there only ones you need. It also can be quite convenient for setting default values for the row.

- (DADataTableRow *) addNewRowWithDataFromDictionary:(NSDictionary *)data inEditMode:(BOOL)editMode

Parameters:

  • data: Dictionary with data for new row
  • editMode: boolean flag which specify do we create new row in EditMode or not

appendTable:

Appends all rows from given table. Finally fires DA_NOTIFICATION_TABLE_CHANGED and DA_NOTIFICATION_TABLE_INDEX_MUST_UPDATE events.

- (void) appendTable:(DADataTable *)newTable

Parameters:

  • newTable: table whose rows will be appended to the current table.

buildIndexForField:

Creates a new DAIndex for the specified field, if none was created before, and returns a reference to the caller. In contrast to indexForField:, the created index will be persisted for future use. It can be removed later, for example to conserve memory, by calling dropIndexForField:.

- (DAIndex *) buildIndexForField:(NSString *)indexField

Parameters:

  • indexField: Name of the field in given %DADataTable% for which we want to build DAIndex

busy

Boolean flag, when it is YES then whole table is in busy mode and any changes can be done here. This usually happens when a table is serialized into a briefcase or creates a delta with changes based on current data table.

@property (readonly) BOOL busy

cancelAllChanges

Cancels all changes in the table. Each row in [table changedRows] will be sent a cancelChangesForRow message.

- (void) cancelAllChanges

cancelChangeForRow:

Cancels changes for given row. If row was added then this method will remove it. If row was deleted then this method will restore it.

- (void) cancelChangeForRow:(DADataTableRow *)row

Parameters:

  • row: Row which changes should be canceled.

cancelChangesForRow:

Cancels changes in a specified row. Deprecated, please use cancelChangeForRow: method instead.

- (void) cancelChangesForRow:(DADataTableRow *)row

Parameters:


changedRows

Returns an array with the subset DADataTableRows in the table that contain pending changes.

@property (readonly) NSArray *changedRows

defaultPredicateEditorRowTemplates

Returns a set of default NSPredicateEditorRowTemplates that can be used to let the user define a custom filter based on the fields in the table. Lookup fields will be handled automatically by these templates, to provide popup buttons for all valid lookup values. See also Working with NSPredicateEditor (Xcode (Mac)) and the Filters sample.

- (NSArray *) defaultPredicateEditorRowTemplates

discardAll

This method discards all changes for the table that was made in edit mode and restores the original values. Finally method turns off edit mode for rows in the table.

- (void) discardAll

dropIndexForField:

Removes an index that was previously created through buildIndexForField:.

- (void) dropIndexForField:(NSString *)indexField

Parameters:

  • indexField:

fieldByName:

Returns the DAFieldDefinition for the field with the given name.

- (DAFieldDefinition *) fieldByName:(NSString *)name

Parameters:


fieldCount

Returns the count of all fields defined in the table.

@property (readonly) NSUInteger fieldCount

fields

Returns an array of all fields (DAFieldDefinition) in the table.

@property (readonly) NSArray *fields

filterUsingPredicate:

Applies a predicate condition to filter the rows in the table. In contrast to rowsFilteredUsingPredicate*, which returns a new filtered array of rows, this method will filter the actual list of rows in the table; all rows not matching the predicate will be discarded from the DADataTable, any pending changes in those rows will be lost.

Use this method if you want to permanently reduce the number of rows maintained by your client application. Use rowsFilteredUsingPredicate*, instead, if you merely want to temporarily work with a reduced subset of the rows, for example for display in a view.

This method triggers the 'TableChanged' notification for the DADataTable.

- (void) filterUsingPredicate:(NSPredicate *)predicate

Parameters:

  • predicate:

getRowWithData:

Builds and returns DADataTableRow instance from given array of the values.

- (DADataTableRow *) getRowWithData:(NSArray *)data

Parameters:

  • data: array of the data for new row.

hasChanges

Returns whether the table contains any rows with open changes (YES) or not (NO). This is equivalent to [changedRows count] > 0.

@property (readonly) BOOL hasChanges

indexForField:

Returns a DAIndex for the specified field. If no index was created before by calling buildIndexForField:, a new index will be created and returned; this newly created index will not be cached for future use.

Use this method to create and obtain a temporary index that can be discarded after use, or to obtain an index previously created through buildIndexForField:.

- (DAIndex *) indexForField:(NSString *)indexField

Parameters:

  • indexField: Name of the field for which we are obtaining index

init

Method initializes new instance of the DADataTable

- (id) init

initWithSchemaTable:

Method initializes new instance of the DADataTable from the given SchemaDataTable. Using this method you can easily setup your DataTable without requesting data.

- (id) initWithSchemaTable:(DASchemaDataTable *)schemaTable

Parameters:

  • schemaTable: Instance of the Schema DataTable

keyFields

Returns an array of primary key (PK) fields (DAFieldDefinition) defined for the table.

@property (readonly) NSArray *keyFields

lock

Locks the table to avoid triggering 'TableChanged' notifications. This can be helpful when a lot of changes will be made to the table at once, but observers that track changes are listening to 'TableChanged' notifications. If data was changed while the table was in locked state, a single 'TableChanged' notification will be fired after the table is unlocked.

- (void) lock

loggedFields

Returns an array of logged and PK fields (DAFieldDefinition) defined for the table.

@property (readonly) NSArray *loggedFields

mergeTable:withPrimaryKey:

Updates the current table with data from the passed, based on a single primary key (PK) field. By comparing values for the key field, the method tries to locate the same row in the destination table and replace it, if found. If not found, the row will be added as new to the destination table. This method does not delete any rows.

It is assumed that both tables have the same structure.

- (void) mergeTable:(DADataTable *)newTable withPrimaryKey:(NSString *)PK

Parameters:

  • newTable: The DADataTable to merge into the current table.
  • PK: primary keys column name.

mergeTable:withPrimaryKeys:

Updates the current table with data from the passed, based on a list of several primary key (PK) fields. By comparing values for the key fields, the method tries to locate the same row in the destination table and replace it, if found. If not found, the row will be added as new to the destination table. This method does not delete any rows.

It is assumed that both tables have the same structure structure.

- (void) mergeTable:(DADataTable *)newTable withPrimaryKeys:(NSArray *)PKs

Parameters:

  • newTable: The DADataTable to merge into the current table.
  • PKs: Array of primary keys column names.

name

Specifies the name of the table.

@property (readonly) NSString *name

postAll

Confirms and fixes all changes in the table made in edit mode

- (void) postAll

predicateEditorRowTemplatesForFieldName:

Returns a set of default NSPredicateEditorRowTemplates that can be used to let the user define a custom filter based on a single field in the table. See also defaultPredicateEditorRowTemplates.

- (NSArray *) predicateEditorRowTemplatesForFieldName:(NSString *)field

Parameters:

  • field: Field name for which we are getting templates

processDelta:andMergeChanges:

Method merges the changes from given delta with the table.

- (void) processDelta:(DADelta *)delta andMergeChanges:(BOOL)applyChanges

Parameters:

  • delta: delta with changes we need to merge into the table
  • applyChanges: boolean flag, if YES then changes will be committed in the table (i.e. table will not have pending changes)

realFields

Returns an array of real fields (DAFieldDefinition) in the table.

@property (readonly) NSArray *realFields

registerRowClass:forTableName:

+ (void) registerRowClass:(Class)class forTableName:(NSString *)name

Parameters:

  • class:
  • name:

removeRow:

Removes a specified row from the table and adds it to changedRows list, so it will be deleted on the server when applying changes.

- (void) removeRow:(DADataTableRow *)row

Parameters:

  • row:

removeRowAtIndex:

Removes a row at a specified index from the table and adds it to the changedRows list, so it will be deleted on the server when applying changes.

- (void) removeRowAtIndex:(NSUInteger)index

Parameters:

  • index: index of the row we want to remove

replaceRowsWithDataFromTable:

Replaces all rows in the table with all rows from given table.

- (void) replaceRowsWithDataFromTable:(DADataTable *)newTable

Parameters:

  • newTable: source table

rowAtIndex:

- (DADataTableRow *) rowAtIndex:(NSInteger)aRow

Parameters:

  • aRow:

rowClass

@property (readonly) Class rowClass

rowCount

Returns the count of all rows in the table.

@property (readonly) NSUInteger rowCount

rows

Returns an array of all rows (DADataTableRow) in the table. In contrast to the other row methods, this property will not construct a new array on the fly, but will return the same aray instance that is used internally by the data table to manage rows. User code should not try to make any changes to this array.

@property (readonly) NSArray *rows

rowsFilteredUsingPredicate:

Returns a new array with a subset of of rows filtered according to the predicate.

- (NSArray *) rowsFilteredUsingPredicate:(NSPredicate *)predicate

Parameters:

  • predicate: Predicate to use for filtering.

rowsFilteredUsingPredicate:localizedCaseInsensitivelySortedByField:ascending:

Returns a new array with a subset of of rows filtered according to the predicate and also sorted by given field using localizedCaseInsensitiveCompare: selector.

- (NSArray *) rowsFilteredUsingPredicate:(NSPredicate *)predicate localizedCaseInsensitivelySortedByField:(NSString *)sortField ascending:(BOOL)ascending

Parameters:

  • predicate: Predicate to use for filtering.
  • sortField: Name of the field for sorting result set.
  • ascending: Boolean flag specifies sorting mode.

rowsFilteredUsingPredicate:sortedByField:ascending:

Returns a new array with a subset of of rows filtered according to the predicate, and also sorted by the specified field.

- (NSArray *) rowsFilteredUsingPredicate:(NSPredicate *)predicate sortedByField:(NSString *)sortField ascending:(BOOL)ascending

Parameters:

  • predicate: Predicate to use for filtering.
  • sortField: FieldName to use for sorting.
  • ascending: YES if ascending and NO if descending.

rowsFinderStyleSortedByField:ascending:

Method returns a new array that lists rows sorted by given field in "Finder style". "Finder style" here means case insencetive with proper strings and numbers comparison - like in OS X Finder application.

- (NSArray *) rowsFinderStyleSortedByField:(NSString *)sortField ascending:(BOOL)ascending

Parameters:

  • sortField: Name of the field that should be used for sorting
  • ascending: Boolean flag, when YES then result array will be sorted in ascending way. When NO then in descending way.

rowsLocalizedCaseInsensitivelySortedByField:ascending:

Method returns a new array that lists rows sorted by given field in the localized case insensetive way.

- (NSArray *) rowsLocalizedCaseInsensitivelySortedByField:(NSString *)sortField ascending:(BOOL)ascending

Parameters:

  • sortField: Name of the field that should be used for sorting
  • ascending: Boolean flag, when YES then result array will be sorted in ascending way. When NO then in descending way.

rowsPartitionedByField:

Returns a dictionary with rows where dictionary key is the value of the given field.

- (NSDictionary *) rowsPartitionedByField:(NSString *)fieldName

Parameters:

  • fieldName: name of the grouping field.

rowsPartitionedByField:includeNull:

Returns a dictionary with rows where dictionary key is the value of the given field.

- (NSDictionary *) rowsPartitionedByField:(NSString *)fieldName includeNull:(BOOL)includeNull

Parameters:

  • fieldName: Name of the field on which we need to group rows
  • includeNull: If YES then for Null values it creates null value group

rowsPartitionedByField:includeNull:sortedByField:ascending:

Returns a dictionary with rows grouped by values of given field. Where grouping value is the key of the dictonary.

- (NSDictionary *) rowsPartitionedByField:(NSString *)fieldName includeNull:(BOOL)includeNull sortedByField:(NSString *)sortfield ascending:(BOOL)ascending

Parameters:

  • fieldName: Name of the field on which we need to group rows
  • includeNull: If YES then it creates null value group for Null values of given field
  • sortfield: Name of the field on which we want to sort result rows
  • ascending: Boolean flag, when YES then grouped rows in dictionary will be sorted in ascending way. When NO then in descending way.

rowsSortedByField:ascending:

Returns a new array with all rows in the table, sorted by the specified field.

- (NSArray *) rowsSortedByField:(NSString *)sortField ascending:(BOOL)ascending

Parameters:

  • sortField: Name of the field on which we want to sort result rows
  • ascending: Boolean flag, when YES then grouped rows in dictionary will be sorted in ascending way. When NO then in descending way.

unlock

Unlocks the table to allow triggering 'TableChanged' notifications. If data was changed while the table was in locked state, a single 'TableChanged' notification will be fired when the table gets unlocked.

- (void) unlock

useFullDelta  assign

@property (assign) BOOL useFullDelta

 

busy

Boolean flag, when it is YES then whole table is in busy mode and any changes can be done here. This usually happens when a table is serialized into a briefcase or creates a delta with changes based on current data table.

@property (readonly) BOOL busy

changedRows

Returns an array with the subset DADataTableRows in the table that contain pending changes.

@property (readonly) NSArray *changedRows

fieldCount

Returns the count of all fields defined in the table.

@property (readonly) NSUInteger fieldCount

fields

Returns an array of all fields (DAFieldDefinition) in the table.

@property (readonly) NSArray *fields

hasChanges

Returns whether the table contains any rows with open changes (YES) or not (NO). This is equivalent to [changedRows count] > 0.

@property (readonly) BOOL hasChanges

keyFields

Returns an array of primary key (PK) fields (DAFieldDefinition) defined for the table.

@property (readonly) NSArray *keyFields

loggedFields

Returns an array of logged and PK fields (DAFieldDefinition) defined for the table.

@property (readonly) NSArray *loggedFields

name

Specifies the name of the table.

@property (readonly) NSString *name

realFields

Returns an array of real fields (DAFieldDefinition) in the table.

@property (readonly) NSArray *realFields

rowClass

@property (readonly) Class rowClass

rowCount

Returns the count of all rows in the table.

@property (readonly) NSUInteger rowCount

rows

Returns an array of all rows (DADataTableRow) in the table. In contrast to the other row methods, this property will not construct a new array on the fly, but will return the same aray instance that is used internally by the data table to manage rows. User code should not try to make any changes to this array.

@property (readonly) NSArray *rows

useFullDelta  assign

@property (assign) BOOL useFullDelta

 

registerRowClass:forTableName:

+ (void) registerRowClass:(Class)class forTableName:(NSString *)name

Parameters:

  • class:
  • name:

 

addCalculatedField:

Adds a new calculated field to the table. Please refer to the documentation for DACalculatedFieldDefinition for more details.

- (void) addCalculatedField:(DACalculatedFieldDefinition *)field

Parameters:


addCalculatedFieldName:dataType:target:selector:

Creates and adds a new calculated field to the table. Please refer to the documentation of DACalculatedFieldDefinition for more details.

- (DACalculatedFieldDefinition *) addCalculatedFieldName:(NSString *)name dataType:(enum DADataType)dataType target:(id)target selector:(SEL)selector

Parameters:

  • name: The unique name for the new calculated field.
  • dataType: The DADataType of the calculated field.
  • target: Reference to the object that will provide the method for calculating this field.
  • selector: Selector of method on the target that will calculate the field.

addCalculatedFieldName:dataType:target:selector:cached:

Adds a new usual or cached calculated field to the table. Please refer to the documentation for DACalculatedFieldDefinition for more details.

- (DACalculatedFieldDefinition *) addCalculatedFieldName:(NSString *)fieldName dataType:(enum DADataType)dataType target:(id)target selector:(SEL)selector cached:(BOOL)cached

Parameters:

  • fieldName: The unique name for the new calculated field.
  • dataType: The DADataType of the calculated field.
  • target: Reference to the object that will provide the method for calculating this field.
  • selector: Selector of method on the target that will calculate the field.
  • cached: Boolean flag. If YES then new cached calculated field will be added to the table. Please refer to the documentation for DACachedCalculatedFieldDefinition for more details.

addLookupField:

Adds lookup field definition to the table. Please refer to the documentation for DALookupFieldDefinition for more details.

- (void) addLookupField:(DALookupFieldDefinition *)field

Parameters:


addLookupFieldName:sourceField:lookupTable:lookupKeyField:lookupResultField:

Creates and appends a lookup field to the table. Please refer to the documentation for DALookupFieldDefinition for more details.

- (DALookupFieldDefinition *) addLookupFieldName:(NSString *)name sourceField:(DAFieldDefinition *)sourceField lookupTable:(DADataTable *)lookupTable lookupKeyField:(DAFieldDefinition *)lookupKeyField lookupResultField:(DAFieldDefinition *)lookupResultField

Parameters:

  • name: The unique name for the new calculated field.
  • sourceField: Initializes the sourceField property.
  • lookupTable: Initializes the lookupTable property.
  • lookupKeyField: Initializes the lookupKeyField property.
  • lookupResultField: Initializes the lookupResultField property.

addNewRow

Appends a new row to the table. If the row has any AutoInc columns, new negative ID values will be generated automatically for these. All other columns will be initialized as null. A reference to the newly added row will be returned to the caller.

This method triggers the 'TableChanged' notification for the DADataTable.

- (DADataTableRow *) addNewRow

addNewRowInEditMode:

Adds a new row for the table.

- (DADataTableRow *) addNewRowInEditMode:(BOOL)editMode

Parameters:

  • editMode: When YES then new row will be added in edit mode. Edit mode is different from the usual mode so that all changes are not visible for the table until they will be fixed by post method or cancelled by discard method.

addNewRowWithDataFromDictionary:inEditMode:

method which allows adding new row with the data from the dictionary in one go. If your table has an autoincrement key field then just omit passing its temporary value in the dictionary. It will be generated automatically by library (otherwize it will throw an exception saying that you cannot specify custom value for autoincrement field.) Also, you don’t need to pass values for ALL fields. You can specify there only ones you need. It also can be quite convenient for setting default values for the row.

- (DADataTableRow *) addNewRowWithDataFromDictionary:(NSDictionary *)data inEditMode:(BOOL)editMode

Parameters:

  • data: Dictionary with data for new row
  • editMode: boolean flag which specify do we create new row in EditMode or not

appendTable:

Appends all rows from given table. Finally fires DA_NOTIFICATION_TABLE_CHANGED and DA_NOTIFICATION_TABLE_INDEX_MUST_UPDATE events.

- (void) appendTable:(DADataTable *)newTable

Parameters:

  • newTable: table whose rows will be appended to the current table.

buildIndexForField:

Creates a new DAIndex for the specified field, if none was created before, and returns a reference to the caller. In contrast to indexForField:, the created index will be persisted for future use. It can be removed later, for example to conserve memory, by calling dropIndexForField:.

- (DAIndex *) buildIndexForField:(NSString *)indexField

Parameters:

  • indexField: Name of the field in given %DADataTable% for which we want to build DAIndex

cancelAllChanges

Cancels all changes in the table. Each row in [table changedRows] will be sent a cancelChangesForRow message.

- (void) cancelAllChanges

cancelChangeForRow:

Cancels changes for given row. If row was added then this method will remove it. If row was deleted then this method will restore it.

- (void) cancelChangeForRow:(DADataTableRow *)row

Parameters:

  • row: Row which changes should be canceled.

cancelChangesForRow:

Cancels changes in a specified row. Deprecated, please use cancelChangeForRow: method instead.

- (void) cancelChangesForRow:(DADataTableRow *)row

Parameters:


defaultPredicateEditorRowTemplates

Returns a set of default NSPredicateEditorRowTemplates that can be used to let the user define a custom filter based on the fields in the table. Lookup fields will be handled automatically by these templates, to provide popup buttons for all valid lookup values. See also Working with NSPredicateEditor (Xcode (Mac)) and the Filters sample.

- (NSArray *) defaultPredicateEditorRowTemplates

discardAll

This method discards all changes for the table that was made in edit mode and restores the original values. Finally method turns off edit mode for rows in the table.

- (void) discardAll

dropIndexForField:

Removes an index that was previously created through buildIndexForField:.

- (void) dropIndexForField:(NSString *)indexField

Parameters:

  • indexField:

fieldByName:

Returns the DAFieldDefinition for the field with the given name.

- (DAFieldDefinition *) fieldByName:(NSString *)name

Parameters:


filterUsingPredicate:

Applies a predicate condition to filter the rows in the table. In contrast to rowsFilteredUsingPredicate*, which returns a new filtered array of rows, this method will filter the actual list of rows in the table; all rows not matching the predicate will be discarded from the DADataTable, any pending changes in those rows will be lost.

Use this method if you want to permanently reduce the number of rows maintained by your client application. Use rowsFilteredUsingPredicate*, instead, if you merely want to temporarily work with a reduced subset of the rows, for example for display in a view.

This method triggers the 'TableChanged' notification for the DADataTable.

- (void) filterUsingPredicate:(NSPredicate *)predicate

Parameters:

  • predicate:

getRowWithData:

Builds and returns DADataTableRow instance from given array of the values.

- (DADataTableRow *) getRowWithData:(NSArray *)data

Parameters:

  • data: array of the data for new row.

indexForField:

Returns a DAIndex for the specified field. If no index was created before by calling buildIndexForField:, a new index will be created and returned; this newly created index will not be cached for future use.

Use this method to create and obtain a temporary index that can be discarded after use, or to obtain an index previously created through buildIndexForField:.

- (DAIndex *) indexForField:(NSString *)indexField

Parameters:

  • indexField: Name of the field for which we are obtaining index

init

Method initializes new instance of the DADataTable

- (id) init

initWithSchemaTable:

Method initializes new instance of the DADataTable from the given SchemaDataTable. Using this method you can easily setup your DataTable without requesting data.

- (id) initWithSchemaTable:(DASchemaDataTable *)schemaTable

Parameters:

  • schemaTable: Instance of the Schema DataTable

lock

Locks the table to avoid triggering 'TableChanged' notifications. This can be helpful when a lot of changes will be made to the table at once, but observers that track changes are listening to 'TableChanged' notifications. If data was changed while the table was in locked state, a single 'TableChanged' notification will be fired after the table is unlocked.

- (void) lock

mergeTable:withPrimaryKey:

Updates the current table with data from the passed, based on a single primary key (PK) field. By comparing values for the key field, the method tries to locate the same row in the destination table and replace it, if found. If not found, the row will be added as new to the destination table. This method does not delete any rows.

It is assumed that both tables have the same structure.

- (void) mergeTable:(DADataTable *)newTable withPrimaryKey:(NSString *)PK

Parameters:

  • newTable: The DADataTable to merge into the current table.
  • PK: primary keys column name.

mergeTable:withPrimaryKeys:

Updates the current table with data from the passed, based on a list of several primary key (PK) fields. By comparing values for the key fields, the method tries to locate the same row in the destination table and replace it, if found. If not found, the row will be added as new to the destination table. This method does not delete any rows.

It is assumed that both tables have the same structure structure.

- (void) mergeTable:(DADataTable *)newTable withPrimaryKeys:(NSArray *)PKs

Parameters:

  • newTable: The DADataTable to merge into the current table.
  • PKs: Array of primary keys column names.

postAll

Confirms and fixes all changes in the table made in edit mode

- (void) postAll

predicateEditorRowTemplatesForFieldName:

Returns a set of default NSPredicateEditorRowTemplates that can be used to let the user define a custom filter based on a single field in the table. See also defaultPredicateEditorRowTemplates.

- (NSArray *) predicateEditorRowTemplatesForFieldName:(NSString *)field

Parameters:

  • field: Field name for which we are getting templates

processDelta:andMergeChanges:

Method merges the changes from given delta with the table.

- (void) processDelta:(DADelta *)delta andMergeChanges:(BOOL)applyChanges

Parameters:

  • delta: delta with changes we need to merge into the table
  • applyChanges: boolean flag, if YES then changes will be committed in the table (i.e. table will not have pending changes)

removeRow:

Removes a specified row from the table and adds it to changedRows list, so it will be deleted on the server when applying changes.

- (void) removeRow:(DADataTableRow *)row

Parameters:

  • row:

removeRowAtIndex:

Removes a row at a specified index from the table and adds it to the changedRows list, so it will be deleted on the server when applying changes.

- (void) removeRowAtIndex:(NSUInteger)index

Parameters:

  • index: index of the row we want to remove

replaceRowsWithDataFromTable:

Replaces all rows in the table with all rows from given table.

- (void) replaceRowsWithDataFromTable:(DADataTable *)newTable

Parameters:

  • newTable: source table

rowAtIndex:

- (DADataTableRow *) rowAtIndex:(NSInteger)aRow

Parameters:

  • aRow:

rowsFilteredUsingPredicate:

Returns a new array with a subset of of rows filtered according to the predicate.

- (NSArray *) rowsFilteredUsingPredicate:(NSPredicate *)predicate

Parameters:

  • predicate: Predicate to use for filtering.

rowsFilteredUsingPredicate:localizedCaseInsensitivelySortedByField:ascending:

Returns a new array with a subset of of rows filtered according to the predicate and also sorted by given field using localizedCaseInsensitiveCompare: selector.

- (NSArray *) rowsFilteredUsingPredicate:(NSPredicate *)predicate localizedCaseInsensitivelySortedByField:(NSString *)sortField ascending:(BOOL)ascending

Parameters:

  • predicate: Predicate to use for filtering.
  • sortField: Name of the field for sorting result set.
  • ascending: Boolean flag specifies sorting mode.

rowsFilteredUsingPredicate:sortedByField:ascending:

Returns a new array with a subset of of rows filtered according to the predicate, and also sorted by the specified field.

- (NSArray *) rowsFilteredUsingPredicate:(NSPredicate *)predicate sortedByField:(NSString *)sortField ascending:(BOOL)ascending

Parameters:

  • predicate: Predicate to use for filtering.
  • sortField: FieldName to use for sorting.
  • ascending: YES if ascending and NO if descending.

rowsFinderStyleSortedByField:ascending:

Method returns a new array that lists rows sorted by given field in "Finder style". "Finder style" here means case insencetive with proper strings and numbers comparison - like in OS X Finder application.

- (NSArray *) rowsFinderStyleSortedByField:(NSString *)sortField ascending:(BOOL)ascending

Parameters:

  • sortField: Name of the field that should be used for sorting
  • ascending: Boolean flag, when YES then result array will be sorted in ascending way. When NO then in descending way.

rowsLocalizedCaseInsensitivelySortedByField:ascending:

Method returns a new array that lists rows sorted by given field in the localized case insensetive way.

- (NSArray *) rowsLocalizedCaseInsensitivelySortedByField:(NSString *)sortField ascending:(BOOL)ascending

Parameters:

  • sortField: Name of the field that should be used for sorting
  • ascending: Boolean flag, when YES then result array will be sorted in ascending way. When NO then in descending way.

rowsPartitionedByField:

Returns a dictionary with rows where dictionary key is the value of the given field.

- (NSDictionary *) rowsPartitionedByField:(NSString *)fieldName

Parameters:

  • fieldName: name of the grouping field.

rowsPartitionedByField:includeNull:

Returns a dictionary with rows where dictionary key is the value of the given field.

- (NSDictionary *) rowsPartitionedByField:(NSString *)fieldName includeNull:(BOOL)includeNull

Parameters:

  • fieldName: Name of the field on which we need to group rows
  • includeNull: If YES then for Null values it creates null value group

rowsPartitionedByField:includeNull:sortedByField:ascending:

Returns a dictionary with rows grouped by values of given field. Where grouping value is the key of the dictonary.

- (NSDictionary *) rowsPartitionedByField:(NSString *)fieldName includeNull:(BOOL)includeNull sortedByField:(NSString *)sortfield ascending:(BOOL)ascending

Parameters:

  • fieldName: Name of the field on which we need to group rows
  • includeNull: If YES then it creates null value group for Null values of given field
  • sortfield: Name of the field on which we want to sort result rows
  • ascending: Boolean flag, when YES then grouped rows in dictionary will be sorted in ascending way. When NO then in descending way.

rowsSortedByField:ascending:

Returns a new array with all rows in the table, sorted by the specified field.

- (NSArray *) rowsSortedByField:(NSString *)sortField ascending:(BOOL)ascending

Parameters:

  • sortField: Name of the field on which we want to sort result rows
  • ascending: Boolean flag, when YES then grouped rows in dictionary will be sorted in ascending way. When NO then in descending way.

unlock

Unlocks the table to allow triggering 'TableChanged' notifications. If data was changed while the table was in locked state, a single 'TableChanged' notification will be fired when the table gets unlocked.

- (void) unlock

Descendants