• 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: Changing formatter for specific cells in the same table column?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing formatter for specific cells in the same table column?


  • Subject: Re: Changing formatter for specific cells in the same table column?
  • From: Kyle Hammond <email@hidden>
  • Date: Sun, 23 Jun 2002 01:26:20 -0500

Hi Ken,

You can change the formatter for individual cells. If you want to change the formatter for particular cells in a column, you'll have to set the formatter for each cell in that column or you'll get undefined results (because the column uses one cell object to draw every cell and the order of drawing is not guaranteed).

In your datasource class, implement the method:

- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;

Your implementation should check the column to see if it's the one you're interested in. Then check the item to see what you've got and which formatter you want to use. Then, simply call

[ cell setFormatter: yourFormatter ];

Where yourFormatter has been decided upon based on the item parameter.

In order to put in a dash, you could use a nil formatter and pass a NSString * of @"-" for the objectValue. For speedy display, you probably want to have an outlet for your other formatter(s). That way you're not allocating/deallocating the formatter for every single cell.

Enjoy.

On Sunday, June 23, 2002, at 12:04 AM, Ken Tozier <email@hidden> wrote:
Is it possible to selectively set the formatter for individual cells in
the same table or outline column? If so, how?

I wrote an outline data source that sums the values for child objects
and displays those sums in the parent objects fields, but for some
fields, summation doesn't make sense (like dates) and I'd like to just
fill these parent cells with dashes. I tried just setting the cell
values to dashes but it seems that if cell data isn't in the right form,
the formatter just displays a blank.

Thanks for any help

Ken Tozier
---------------------
Kyle Hammond
email@hidden

http://www.CodeBlazer.com/ - multimedia software solutions
http://www.isd.net/dsl03002/ - my personal home page
http://cocoabudget.home.att.net/ - Budget for MacOS X home page
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: The Small Developer
  • Next by Date: Learning Cocoa / Cocoa Programming for Mac OS X - comments
  • Previous by thread: Re: Can't get an NSDocument subclass to load nib...
  • Next by thread: How do I prevent initWithFrame (NSView) being called?
  • Index(es):
    • Date
    • Thread