在“主从”中使用弹出按钮

发布于 2024-10-16 08:53:41 字数 1393 浏览 7 评论 0原文

我的基于文档的核心数据应用程序(使用 IB 中的绑定)有两个实体:Employee(带有 employeeName 属性)和 TimeSheet(带有 < strong>timeDescription 和 entryDate 属性)。 EmployeeTimeSheet 具有一对多 (employeeTimeSheet) 关系。

我正在为时间表条目构建主从设置。

对于Master,我有一个一列的tableView,它的绑定到:EmployeeController(使用Employee实体的NSArrayController),arrangedObjects员工姓名

我有一个详细控制器(另一个 NSArrayController),它设置为 NSMutableDictionary,其 contentSet 绑定到 EmployeeControllerselectionemployeeTimeSheet

然后我有 Detail tableView,它有三列,它们各自的 value 绑定到 DetailControllerarrangedObjectsemployeeDetails.employeeName >(第 0 列)、entryDate(第 1 列)和 timeDescription(第 2 列)。

现在一切正常,我可以从主表中选择一名员工,明细表显示与该员工关联的所有考勤表条目。我可以使用选定的员工添加条目,一切都很好。

我的问题是,我不想将 tableView 作为主视图,而是想要一个 NSPopupButton ,从中我可以选择一个员工并查看与该员工关联的所有时间条目。

我已经尝试了内容、值、arrangedObjects、selectedObject(s) 等的每种组合以及我拥有的控制器的每种组合,但无法让 NSPopupButton 以与单列 tableView 类似的方式运行。

我徒劳地搜索了更多关于这方面的信息,并多次阅读了绑定文档,但总是搞混。我觉得这应该比较简单,但我似乎无法理解。在发帖之前我已经绞尽脑汁两天了。

有人能指出我哪里出错了吗?我会发布代码,但这并不合适,因为它主要是 IB 的事情。

比利.

My Document based, Core Data application (using bindings in IB) has two entities, Employee (with an employeeName attribute) and TimeSheet (with timeDescription and entryDate attributes). Employee has a one(employeeDetails)-to-many(employeeTimeSheet) relationship with TimeSheet.

I'm constructing a Master-Detail set up for a TimeSheet entry.

For the Master I've got a one column tableView which has it's value bound to: EmployeeController (an NSArrayController using the Employee entity), arrangedObjects, employeeName.

I have a detailController (another NSArrayController) which is set up as an NSMutableDictionary which has it's contentSet bound to EmployeeController, selection, employeeTimeSheet.

I then have Detail tableView which has three columns, with their respective value bound to DetailController, arrangedObjects, employeeDetails.employeeName(column 0), entryDate(column 1) and timeDescription(column 2).

Now this all works fine, I can select an Employee from the Master Table and the Detail Table shows all the TimeSheet entries associated with that Employee. I can add entries using the selected Employee, everything works great.

My problem is, instead of having a tableView as a Master view, I wanted an NSPopupButton in it's place from which I can select an Employee and view all the time entries associated with that Employee.

I've tried every combination of content, value, arrangedObjects, selectedObject(s) etc. with every combination of the controllers I have but cannot get the NSPopupButton to behave in a similar way to the single column tableView.

I've searched in vain for more information on this and read through the bindings documentation several times but just keep getting mixed up. I feel this should be relatively simple but I just can't seem to get it. I've been racking my brains for almost two days now before posting on here.

Can anybody point out where I'm going wrong? I'd post code but that isn't really appropriate seeing it's mainly an IB thing.

Billy.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甚是思念 2024-10-23 08:53:41

顺便说一句:detailController 将“自动”填充一个新的员工对象。确保将“managementObjectContext”设置为同一控制器(employeeController)。

By the way: the detailController will populated with a new employee object "automatically". Make sure to set "managedObjectContext" to the same controller (employeeController).

╰ゝ天使的微笑 2024-10-23 08:53:41

好的,我找到了。我知道在这里发帖后我会立即找到它。

我将 NSPopupButton content 绑定到 EmployeeControllerarrangedObjectscontentValue 绑定到 EmployeeController、< strong>arrangedObjects、employeeName,以及 selectedIndex 到 EmployeeControllerselectionIndex

效果很好。

比利.

Ok, I found it. I knew that after posting on here I'd find it straight away.

I bound the NSPopupButton content to EmployeeController, arrangedObjects, contentValue to EmployeeController, arrangedObjects, employeeName, and it's selectedIndex to EmployeeController, selectionIndex.

Works great.

Billy.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文