Re: table bindings, value transformer per row?
Re: table bindings, value transformer per row?
- Subject: Re: table bindings, value transformer per row?
- From: "email@hidden" <email@hidden>
- Date: Sat, 18 Oct 2008 09:54:36 -0700
thanx for this.
i've been using the willDisplayCell: delegate method to "swap"
formatters as necessary, but i'd never thought of using it to "swap"
the cell's value! i will add this to my "bag o' tricks" for possible
future use.
for my current situation, i removed the use of the value transformer
from my binding, and bound the column to different data in my model
and apply appropriate formatter's as necessary. note that going this
way doesn't impact sorting.
thanx,
ken
At 6:26 PM -0700 10/17/08, Ron Lue-Sang wrote:
Nope. No way to swap out the valuetransformer of the binding per row.
You can use part of Keary's suggestion tho. Don't set a
valuetransformer at all in the binding for the column. Use the
willDisplayCell: delegate method to take the value out of the cell,
apply your own value transformations based on the row or whatever,
and then set the new value on the cell.
Unfortunately, this setup will defeat the sorting behaviour Cocoa
Bindings gives you for free. Our automatic support for sorting, for
this column, will be wrong. I'd only suggest doing this for a column
that's not sortable/filterable. Otherwise, you should really just
add accessors to your model objects if you can (or create wrappers
for them if you have to) that give you the transformed properties.
--------------------------
RONZILLA
On Oct 16, 2008, at 4:59 PM,
<mailto:email@hidden>email@hidden wrote:
i was asking about the "value transformer" that is specified for
the binding. i am aware that it is quite easy to change formatters.
thanx anyway,
ken
At 5:49 PM -0600 10/16/08, Keary Suska wrote:
On Oct 15, 2008, at 7:35 PM,
<mailto:email@hidden>email@hidden wrote:
i've got a bound table view. is it possible to use a different
value transformer based on which row of the table is being
displayed/edited? and if so, how?
Yes, you can. The formatter is a property of the cell, and not the
column, per se. You need an object that is the tableview's
delegate, then implement
-tableView:willDisplayCell:forTableColumn:row:. NSCell has a
-setFormatter: method for your convenience. I have used this
successfully without error, but I haven't performance tested it. I
don't suspect that it is much slower.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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