FROM : Brian Weitzner
DATE : Fri Aug 04 17:24:36 2006
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
DATE : Fri Aug 04 17:24:36 2006
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
| Related mails | Author | Date |
|---|---|---|
| No related mails found. | ||






Cocoa mail archive

