On Jun 5, 2009, at 4:01 PM, Steven Hamilton wrote:

Hi,
I have an NSTableview populated by bindings to Core Data. In one column I have a popupbutton (bad idea as its slow, I know) and in another I have a checkbox. I only want the checkbox to be available when certain items from the popupbutton are selected. To try and do this I've implemented;

- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
        if ([[tableColumn identifier] isEqualToString:@"budget"]) {
                //Fetch account type
Account *selectedAccount = [[accountsController arrangedObjects] objectAtIndex:row]; if ([[selectedAccount valueForKeyPath:@"type.name"] isEqualToString:@"Assets"] || [[selectedAccount valueForKeyPath:@"type.name"] isEqualToString:@"Liabilities"]){
                        [cell setEnabled:FALSE];
                         [selectedAccount setValue:FALSE 
forKey:@"envelopeVisible"];
                }
        }
}

This disables the checkbox which nearly works barring a slight issue with refresh. I'd much rather though just display nothing at all and only have the checkbox visible on the rows that need it. Is there a way to change the cell to just blank rather than a checkbox? Or am I going about this the wrong way and set the column to blank and programmatically create checkboxes when I need them?

Return a plain NSCell with the -stringValue set to @"" from this method:

- (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn: (NSTableColumn *)tableColumn row:(NSInteger)row AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;

You may have to use willDisplayCell to set the objectValue to the blank string to avoid what bindings fills it up with.

corbin


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to