nstableview

Sorting NSTableView

纵然是瞬间 提交于 2019-12-05 05:35:14
I have two coloumn in NSTableView as Name and Salary with 5-10 values. I want to sort these coloumn after click on header of both the column. There is lots of data present in Internet but I am not able to use these. Please help me to do this in cocoa. Thanks in advance and appreciate any help. rounak Each table column has a method setSortDescriptorPrototype Sort descriptors are ways of telling the array how to sort itself (ascending, descending, ignoring case etc.) Iterate over each of the columns you want as sortable and call this method on each of those columns, and pass the required sort

NSTableView with multiple columns

左心房为你撑大大i 提交于 2019-12-05 02:48:28
问题 What is an easy way to set up my NSTableView with multiple columns to only display certain data in one column. I have the IBOutlets set up, but I don't know where to go from there. 回答1: Assuming you're not using Cocoa Bindings/Core Data, you can display data in an NSTableView by implementing two methods from the NSTableViewDataSource protocol. Typically your controller will implement the protocol, so open the controller .m file and add these methods to the controller's @implementation : -

Core Data Fetched Results Controller and Custom Section Header

*爱你&永不变心* 提交于 2019-12-05 01:19:47
问题 I am familiar with the common and basic use of a NSFetchedResultsController managing the rows of a table, but I have an interesting problem. My data is organized as such: Schedule <--->> Day <--->> Route. I currently have a table view that has Schedules with a fetch controller managing the creation and deletion of Schedules. I now want to create a table view for Routes/Days. I would like to list a Route on every row, and create custom section headers that correspond to information within the

NSTableview Change the highlight colour

南笙酒味 提交于 2019-12-04 23:15:48
问题 I am developing a MAC application and included the tableView. Want to change the Colour of selected row to yellow. 回答1: Set this on your table view: [yourtableview setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone]; And implement the following delegate method of NSTableView as: - (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { if ([[aTableView selectedRowIndexes] containsIndex:rowIndex])

Setting one side of an NSSplitView programmatically

≡放荡痞女 提交于 2019-12-04 22:13:12
问题 I've got an NSSplitView and on the left side I've got a tableView (like a source list) and depending on row selection, I want to change the the right side of the split view. I can't quite figure out how to do this. When I add my desired subview to the splitview, it adds another split (so now there's 3 views total... not what I wanted). [mySplitView addSubview:myCustomView]; How do I properly set the right side of my splitView? Update Using [mySplitView replaceSubview:[[mySplitView subviews]

How to set background color of cell with NSButtoncell type in NSTableView?

一世执手 提交于 2019-12-04 20:52:01
This is my table view delegate: - (void)tableView:(NSTableView *)tableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)tableColumn row:(int)row { id theRecord; NSMutableString *gid; theRecord = [tableDataSource objectAtIndex:row]; gid = [theRecord objectForKey:@"gid"]; if (([gid intValue] % 2) != 0) { [aCell setDrawsBackground: YES]; [aCell setBackgroundColor: [NSColor colorWithCalibratedRed: 237.0 / 255.0 green: 243.0 / 255.0 blue: 254.0 / 255.0 alpha: 1.0]]; } else { [aCell setDrawsBackground: NO]; } } It works fine to display normal cell but the tableview get frozen after I

How to disable sorting in NSTableVIew?

拥有回忆 提交于 2019-12-04 20:02:36
问题 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. 回答1: Sorting of the NSTableView is done by its sortDescriptors , see here. An NSTableColumn uses its sortDescriptorPrototype (see here) to generate the sort

Differences between NSTableView and NSCollectionView

末鹿安然 提交于 2019-12-04 18:02:45
I'm trying to decide which path to take for developing my Snow Leopard app. First, I should preface with the obvious differences: NSTableView can have multiple columns of data for representing different parts of the same "element" of data (a row) where NSCollectionView can display a grid of data as well, but every row+column combo is its own element. For my purposes, assume I'm dealing with a single column. As far as I can tell, NSCollectionView items are NSView s which all must be of the same dimensions. Also, unlike NSTableView , collectionview items are copied to the NSCollectionView

Automatic table column Indentifier in NSTableView

十年热恋 提交于 2019-12-04 17:53:38
After bit of research, I was able to populate the NSTableView with some date via the "identifier way" like you assign unique identifier to each column. However, I would like to now if there is a way to populate NSTableView without providing the identifier to the columns and how? To be more clear - the use of automatic table column identifier, which is slightly described here: About the automatic table column identifier and and I find a way how to enumerate or get the index of the column by this expression: //in the objectValueForTableColumn blah blah blah method int columnIndex = [

reloadData in NSTableView but keep current selection

荒凉一梦 提交于 2019-12-04 17:11:26
问题 I have an NSTableView showing the contents of a directory. I watch for FSEvents, and each time I get an event I reload my table view. Unfortunately, the current selection then disappears. Is there a way to avoid that? 回答1: It depends on how you populate your NSTableView. If you have the table view bound to an NSArrayController, which in turn contain the items that your table view is displaying, then the NSArrayController has an option to preserve the selection. You can select it (or not) from