简体   繁体   English

NSTableView列编辑与自动刷新表

[英]NSTableView column editing with auto refresh of table

I have a NSTable that is being refreshed in each 5 seconds with new data. 我有一个NSTable,每5秒钟会刷新一次新数据。 Now i have to add a new column to edit that user can edit. 现在,我必须添加一个新列来编辑该用户可以编辑的列。 At the first time it is working edit column becomes un editable when table is being refreshed after 5 second. 第一次使用时,在5秒钟后刷新表时,编辑列将变为不可编辑。

So far example i have started editing the column and writing long text but just after 5 second table got refreshed and all text was gone. 到目前为止,我已经开始编辑该列并编写长文本,但是仅在5秒后表格刷新并且所有文本都消失了。

How to handle this situation? 如何处理这种情况? One solution could be to stop refresh of table when it is in edit mode. 一种解决方案是在表处于编辑模式时停止刷新表。 Please suggest. 请提出建议。

Regards, MP. 问候,国会议员。

Use the methods that reload data for only certain rows/columns and refresh all the cells except the one you're editing. 使用仅重新加载某些行/列的数据并刷新除正在编辑的单元格以外的所有单元格的方法。

So you would use tableView:shouldEditTableColumn:row: to detect when a cell begins editing. 因此,您将使用tableView:shouldEditTableColumn:row:来检测单元格何时开始编辑。 Then, you would keep track of the this column and this row as the currently editing row and column. 然后,您将跟踪此列和该行作为当前编辑的行和列。

Then, you would use reloadDataForRowIndexes:columnIndexes: to reload all row/column indexes except for the one that corresponds to the currently editing cell. 然后,您将使用reloadDataForRowIndexes:columnIndexes:重新加载所有行/列索引,但与当前编辑单元格相对应的索引除外。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM