• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Populating NSOutlineView Programatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Populating NSOutlineView Programatically


  • Subject: Populating NSOutlineView Programatically
  • From: Paul Naro <email@hidden>
  • Date: Sat, 7 Jun 2003 07:11:05 -0600

I am trying to populate a list of database tablenames and fields into
an NSOutlineView. That I WANT to occur is when a user connects to a
database, they have the ability to click on a "Tables" option inside of
of a NSOutlineView. That will display a list of tables. Clicking on a
tablename will display a list of field attributes and so on. Any help
is greatly appreciated!

It works fine getting a list of table names, but I must be missing
something stupid to get the field attributes inserted. My datasource
looks like this ...


Node *selectedItem;
Node *newNode;
int selectedRow = 0; // Top initial row
selectedItem = [outlineView itemAtRow:selectedRow];

// drop all the data because there is a new connection
if ([selectedItem childrenCount] > 0) {
[selectedItem removeChildren];
}

/* Build the list of table names for the current connection */
conn = [self connectToDB];
res = [conn executeQuery:@"SELECT tablename ... "];
rset = [res resultset];
tableNum = [rset rows];
if (tableNum > 0) {
for (i = 0;i < tableNum; i++) {
newNode = [[Node alloc] init];
[newNode setItemName: [rset dataForFieldAtIndex:0 row:i]];
[selectedItem addChild: newNode];
[newNode release];
}

This correctly inserts each tablename node. Here is where the problem
starts. I have to get the attributes for each tablename so I thought
the best way would be to query each tablename, get a list of the fields
and make them a child of the currently selected table node like this ...

for (i = 1;i < tableNum; i++) { // First table starts at 1
selectedItem = [outlineView itemAtRow:i]; // should get the
table in question
res1 = [conn executeQuery:@"select query for table attributes
goes here"];
rset1 = [res1 resultset];
fieldNum = [rset1 rows];
for (x = 0; x < fieldNum ; x++) {
newNode = [[Node alloc] init];
[newNode setItemName: [rset1 dataForFieldAtIndex:0 row:x]];
[selectedItem addChild: newNode];
[newNode release];
}
}
}

The query executes and returns the correct results, but fails to insert
the children into the correct parent. (any parent). I feel it is
something stupid, but have playing around this for hours without
success.

TIA

Regards,

Paul Naro
Xcel Technologies, Inc.
719-332-4884
http://www.xceltech.net/
AOL IM: PaulAtXcel
_______________________________________________
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.

  • Prev by Date: Re: NSTableView advice ...
  • Next by Date: Re: Select a carbon window within a Cocoa application
  • Previous by thread: Very odd ScreenSaverView/setAnimationTimeInterval: problem
  • Next by thread: Writing ID3 Tags
  • Index(es):
    • Date
    • Thread