如何禁用NSTableVIew中的排序? [英] How to disable sorting in NSTableVIew?
问题描述
当我单击特定的标题列时,我就有一个NSTableView,表中的数据被颠倒或颠倒排序.我已经检查了NSTableView
和NSTableColumn
,但是找不到禁用此功能的任何方法.如果有人可以通过单击特定列的标题来禁用此排序功能,我将承担责任.
I have a an NSTableView when ever I click on a specific header column the data in the table get reversed or sort upside down. I have checked NSTableView
as well as NSTableColumn
but couldn't find any method that disables this. I would be obliged if anyone can help in disabling this sorting on clicking on the header of a particular column.
推荐答案
NSTableView
的排序由其sortDescriptors
完成,请参见
Sorting of the NSTableView
is done by its sortDescriptors
, see here.
NSTableColumn
使用其sortDescriptorPrototype
(请参见
An NSTableColumn
uses its sortDescriptorPrototype
(see here) to generate the sort descriptor of the NSTableView
, depending on how many times you clicked the column header, etc.
如果使用dataSource
管理数据,则将通过委托方法tableView:sortDescriptorsDidChange:
传达排序描述符,请参见
If you use dataSource
to manage the data, then the sort descriptor is communicated via the delegate method tableView:sortDescriptorsDidChange:
, see here. You just need to ignore the change message to stop sorting.
如果使用Cocoa绑定来管理数据,则排序描述符由表列生成并设置为NSArrayController
.要停止它,只需打开表列绑定的检查器,选择value
,然后取消选中创建排序描述符".
If you use Cocoa bindings to manage the data, the sort descriptor is generated by the table column and set to the NSArrayController
. To stop it, just open the inspector of the binding of the table column, select value
, and uncheck "Creates Sort Descriptor."
这篇关于如何禁用NSTableVIew中的排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!