• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Replacing a tableView Cell with null
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replacing a tableView Cell with null


  • Subject: Re: Replacing a tableView Cell with null
  • From: Corbin Dunn <email@hidden>
  • Date: Fri, 05 Jun 2009 16:33:04 -0700


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 (email@hidden)

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:
This email sent to email@hidden


References: 
 >Replacing a tableView Cell with null (From: Steven Hamilton <email@hidden>)

  • Prev by Date: Re: Hiding Glyphs
  • Next by Date: Re: Hiding Glyphs
  • Previous by thread: Replacing a tableView Cell with null
  • Next by thread: Re: Replacing a tableView Cell with null
  • Index(es):
    • Date
    • Thread