Hiding/Showing Table Columns
Hiding/Showing Table Columns
- Subject: Hiding/Showing Table Columns
- From: "Jonathan E. Jackel" <email@hidden>
- Date: Wed, 29 May 2002 17:03:57 -0400
I have a tableview with many possible columns, all set up and formatted in
my nib. I would like the user to be able to show/hide/move columns at will.
Moving columns is no problem because NSTableView manages that, but I want
the user to see the same column order next time the document is opened. I
also want the user to be able to have different columns visible, or to have
the columns in a different order, in different documents, so an "autosave"
doesn't seem like it will work.
There are three problems, as I see it:
A) How to hide columns (pretty easy with removeTableColumn -- if you don't
care about getting them back);
B) How to make them reappear again (with formatting/editability intact);
C) How to save the configuration information. Since each document could
have a different set of columns, it seems to me that that the configuration
should be archived/unarchived with the data model, rather than (or perhaps
in addition to) being saved as a user preference. The prefs might determine
the default config for the table, but the archived version would determine
how a saved document looks.
My initial thought is to use three collections, as follows:
1. The identifiers of the visible columns in order. This collection
(probably an NSArray) would be archived with the data (and possibly created
in the archiving process). When the file is opened, this array would be
used to put the visible columns in the right order.
2. The identifiers of the removed columns. This collection (probably an
NSArray) would be archived with the data (and possibly created in the
archiving process). When the file is opened, this array would be used to
remove the "hidden" columns.
3. The removed NSTableColumn objects. This collection (probably an
NSDictionary, with the column headings as keys) would allow me to restore
removed table columns by taking them out of the dictionary.
The user would be able to get a list of all possible columns as checkbox
buttons. Checking a box would cause the app add the corresponding table
column to the tableview and remove it from collection #3. The reverse would
happen if the box were unchecked. There would be no need to archive #3
because the table columns are in the nib containing the tableview.
This all seems too darned complicated. Maybe I can do without #2, but
archive #3.
What do we think? Anyone have a pointer to an example?
Jonathan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.