Grid / Custom Cell Column Not Sorting


#1

I’m having a problem getting my custom cell columns to sort when the rest of the data is sorted.  Here’s an example of the problem.  What am I missing?

http://www.cattail.nu/temp/sortingProblem.zip


#2

Greetings Program!

In your dataGridDataSourceHelper, you don’t need to get the managed object from the _data as it is passed in the sourceObject:(id)object.

Try this:

- (BOOL)dataGridDataSourceHelper:(SDataGridDataSourceHelper *)helper populateCell:(SDataGridCell *)cell withValue:(id)value forProperty:(NSString *)propertyKey sourceObject:(id)object {

  if ([propertyKey isEqualToString:@"picture"]) {
	  NSLog(@"Object: %@", object);
    PictureCell *pictureCell = (PictureCell *) cell;
    //NSManagedObject* managedObject = _data[cell.coordinate.row.rowIndex];
    if ([object valueForKey:propertyKey]!=nil) {
      pictureCell.image = [UIImage imageWithData:[object valueForKey:propertyKey]];
    } else {
      pictureCell.image = nil;
    }
    return YES;
  }

  return NO;
}

Wg


#3

Thank you!  That works!  If I understand correctly, cell.coordinate.row.rowIndex is not valid as an index for user sorted data, which makes sense if the original array isn’t touched.  I’ll have to modify my custom cells (that do something) to pass around the object pointer, too.