在绑定到NSArrayController的NSTableView中显示行索引 [英] Displaying row index in an NSTableView bound to NSArrayController

查看:145
本文介绍了在绑定到NSArrayController的NSTableView中显示行索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NSTableView绑定到一个NSArrayController。我想有一个表列显示表行的索引。这是很容易做到当你自己实现NSTableDataSource,但我不能弄明白与绑定表视图。
我想我在这里寻找类似的@count键路径,它给了我计数arrangeObjects(即@index),但这显然是缺少。

I have an NSTableView which is bound to an NSArrayController. I would like to have one of the table columns showing the index of the table row. This is easy enough to do when you implement NSTableDataSource yourself but I can't figure it out with a bound table view. I guess I'm looking here for something like the @count key path which gives me the count of arrangedObjects (that is @index) but this is obviously missing.

两个澄清:


  1. 每行显示的索引是该行的索引,该数据实际上被布置在模型或阵列控制器中。例如,如果整个数据是10000个项目,那么索引应该从1到10000,如果用户输入搜索项并且表只显示4个项目,则数字应该从1到4,即使显示的项目实际上来自原始数组。

  2. 我需要这个,因为我被客户要求这样做:-)。客户端需要一种能够估计某行之前或之后的行数的方法。例如,Hi可能想知道添加了多少行。


推荐答案

根据我的理解,您可以选择不绑定表列,一个数据源。我记得NSTableView支持这种双模式操作,但是找不到任何文档来确认它。

As I understand it, you could choose not to bind that table column, and use a datasource instead. I recall NSTableView supports this sort of "dual mode" operation, but can't find any docs to confirm it.

这篇关于在绑定到NSArrayController的NSTableView中显示行索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆