Re: Replacing a tableView Cell with null
Re: Replacing a tableView Cell with null
- Subject: Re: Replacing a tableView Cell with null
- From: Steven Hamilton <email@hidden>
- Date: Sat, 6 Jun 2009 11:59:34 +1000
Begin forwarded message:
From: Steven Hamilton <email@hidden>
Date: 6 June 2009 11:59:18 AM
To: Corbin Dunn <email@hidden>
Subject: Re: Replacing a tableView Cell with null
On 06/06/2009, at 9:33 AM, Corbin Dunn wrote:
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;
Thanks a lot, that seems to work really well. However, because I'm
only specifying the cell for one column how do I get out of the
method without messing with the other columns. I get the following
warning;
- (NSCell *)tableView:(NSTableView *)tableView
dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
NSCell *cell = [NSCell alloc];
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 initTextCell:@""];
return (cell);
}
}
return;
}
warning: 'return' with no value, in function returning non-void
_______________________________________________
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