Re: Filtering a table view using NSSearchField
Re: Filtering a table view using NSSearchField
- Subject: Re: Filtering a table view using NSSearchField
- From: PCWiz <email@hidden>
- Date: Wed, 16 Sep 2009 07:22:49 -0600
I found a very simple way to do this. Just bind the NSSearchFields
"predicate" binding to the Array Controllers filterPredicate key. Then
change the Predicate Format to "myKeyPath contains[c] $value" where
myKeyPath is the key path in the array controller that you want to
filter from. This worked for me. good luck!
On 2009-09-15, at 10:48 PM, BareFeet <email@hidden>
wrote:
Hi Matt,
I'm trying to filter a NSTableView using the contents of an
NSSearchField. I have an Array Controller and table columns bound to
key paths in the array controller. So for example I have the table
column for name is bound to Array Controller.arrangedObjects.name.
What I want to do now is filter the contents of the table view
(based on the name column) using text typed into an NSSearchField.
I know this is somehow possible using bindings and predicates, but
im not sure exactly how to do it.
Download my app Thucydides. It's short and sweet and comes with
example
source code which exemplifies exactly what you're describing. In
fact, what
you're describing is just about all it does.
I had a look at your code. As best I can tell, the filtering doesn't
use Bindings or predicates at all (though the display of the actual
controller array etc uses bindings). You just change the array
(which you called "found") to only include rows from the complete
array (which you called "urls").
Am I missing something in your code that uses bindings for the
search field and filtering?
Is there a way to simply bind the search field content to a filter
key path?
Thanks,
Tom
BareFeet
_______________________________________________
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
_______________________________________________
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