使表格的显示依赖于 Interface Builder 中另一个表格中的选择
我已经设置了一个带有两个 NSTableView 的窗口。在核心数据中,我设置了两个实体,其中一个包含另一个更大分组的成员(例如汽车
和制造商
)。我为每个实体设置了入口页面,并且它们在那里运行得很好(尝试从下拉菜单中的多对一中进行选择时没有错误)。我现在想做的是更进一步,这样当我在主 NSTableView
中选择一个 manufacturer
时,汽车列表
与该 manufacturer
相关的 > 将出现在第二个 NSTableView
中。
我尝试使用类似于我为 manufacturer
弹出按钮所做的绑定,从 cars
实体提供值,但它只是显示所有的列表car
条目,无论我选择哪个manufacturer
。但是,我没有看到任何用于过滤它的谓词选项,如果我将绑定的关键路径设置为 manufacturer.cars
,它会显示关系错误。如何过滤子表中显示的内容?
I've got a window set up with two NSTableViews. In Core Data I have two entities set up, one of them containing members of the other, larger grouping (e.g. cars
and manufacturers
). I've got entry pages set up for each entity and they play nicely there (no faulting when trying to select from a many-to-one in a drop menu). What I'm trying to do now is take that one step further so that when I select a manufacturer
in the main NSTableView
, the list of cars
related to that manufacuturer
will appear in the second NSTableView
.
I've tried using bindings similar to what I've done for the manufacturer
popup button, feeding the value from the cars
entity, however it's simply showing a list of all the car
entries, regardless of which manufacturer
I select. I don't see any options for a predicate to filter it, however, and if I set the binding's key path to manufacturer.cars
, it shows a relationship fault. How can I filter what gets displayed in the child table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有两个 NSArrayController。将 cars 控制器的
contentArray
绑定到Manufacturer控制器;控制器键是selection
(即选定的制造商),模型键路径是包含制造商汽车的属性的路径。然后,将 cars 表视图的列绑定到 cars 控制器的
arrangedObjects
属性。Have two NSArrayControllers. Bind the
contentArray
of the cars controller to the manufacturers controller; the controller key isselection
(i.e., the selected manufacturer), and the model key path is that of the property containing the manufacturer's cars.Then, bind the cars table view's columns to properties of the cars controller's
arrangedObjects
.