The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Adding Columns to a DataSet

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Adding Columns to a DataSet Posted: Oct 30, 2003 7:38 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Adding Columns to a DataSet
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement
Here's a perennial favorite in VisualWorks: You have a dataset widget, and you would like to dynamically add a column at runtime. How do you do that? Well, there's been a support tip on this for years - and I made use of that tip in BottomFeeder. The all new view has 2 modes:
  • Show a restricted tree, with only the new items
  • Show all new items in a 2 pane (no tree) view

For the latter view, we add a column (with the feed name) to the dataset, so that you can tell where the item in question came from. So how is that accomplished? Here's the relevant code snippet:


	table := self widgetAt: #feedListID.
	columns := table columnDescriptors asOrderedCollection.
	columnSpec := self class zoomedColumnSpec decodeAsLiteralArray.
	columns addFirst: (columnSpec columnWithBuilder: self currentBuilder).
	table setColumnDescriptors: columns.
	table invalidate.
	self hasAddedColumn: true 

The spec is the spec for a single column - I extracted a column spec (copy) from a dataset spec, changed the attributes to match what I wanted, then saved the result as a class method. Then, at runtime, I can grab that spec object, and just slam it into the dataset. It can be removed just as easily. That's it!

Read: Adding Columns to a DataSet

Topic: Why the spam doesn't stop Previous Topic   Next Topic Topic: PDC - not for non Softies?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use