NSTableView: remove all columns and enable sorting.
NSTableView: remove all columns and enable sorting.
- Subject: NSTableView: remove all columns and enable sorting.
- From: Brian Weitzner <email@hidden>
- Date: Fri, 4 Aug 2006 11:24:36 -0400
Hi all,
I'm using an NSTableView to display the results of a MySQL
query. Since different tables in the database can queried, I had to
make the columns programmatically after the query. So what I want to
do is remove all the columns before it starts to add the new ones, so
the results of previous queries aren't being displayed. Is there a
good way to do this? I know about removeTableColumn: but then the
problem becomes how do I get the names of the NSTableColumn to be
removed? Here is the code used to make the columns:
NSString *name;
NSTableColumn *column;
columnNameEnumerator = [[queryResult fetchFieldsName] objectEnumerator];
while(name = [columnNameEnumerator nextObject]) {
column = [[NSTableColumn alloc] initWithIdentifier:name];
[[column headerCell] setStringValue:name]; //Used to set the column
title.
[tableView addTableColumn:column];
[column release]; //The table view will retain the object so release
it.
}
Also, I would like to be able to sort this data. I read through the
Sorting NSTableView thread from a few days ago, and I must admit, it
seemed a little bit over my head. Unfortunately, I cannot figure out
how to enable sorting completely programmatically. The solution
posted involved setting sort keys in IB, which I cannot do. Does
anyone know how to do this? Thanks!
--
Brian Weitzner
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden