I have a tableview with 4 columns. The fist one has some text and the other 3 are checkboxes.
I need to disable 2 of the 3 checkboxes in one particular row. I keep the row number on an NSInteger variable.
I've implemented:
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
Where I check the columns identifier to know whether I am at the right column, once I know that I check if the row is correct and set the cell to disable. Code follows:
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
if(([[aTableColumn identifier] isEqualToString:@"column1"]) || ([[aTableColumn identifier] isEqualToString:@"column2"]))
{
if (rowIndex == myindex) // myindex holds the row index where I need to disable the cells
{
[aCell setEnabled:NO];
}
}
else
{
return;
}
}
What happens is strange. Colum1 and Colum2 for my specific row are disabled until I click another row, then all the rows get these two columns disabled.
How do I disable these two very specific cells (only in myindex
row and only column1
and column2
)?
this is a Mac OS X app, not an iOS app.
Thanks
You have to explicitly set the enabled
property each time for both cases.
//...
else
{
[aCell setEnabled:YES];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With