0

I am working with Spec library in Pharo 3 and I have found no way to add a header to a multi column list. However, adding headers is feasible through TreeColumnModel and TreeModel like this:

| m col1 col2 |
m := TreeModel new.
m roots: #(#a #b #c #d).
m rootNodeHolder: [ :item | 
    TreeNodeModel new
        content: item;
        icon: Smalltalk ui icons smallConfigurationIcon ].
m openWithSpec.
col1 := TreeColumnModel new
    displayBlock: [ :node | node content asString ];
    headerLabel: 'Character'.
col2 := TreeColumnModel new
    displayBlock: [ :node | (Character value: node content asString first asciiValue + 1) asString ];
    headerLabel: 'Character +1';
    headerIcon: Smalltalk ui icons smallBackIcon.
m
    columns: {col1. col2};
    acceptDropBlock: [ :transfer :event :source :receiver | self halt ].
col2 
    headerLabel: 'Character +2';
    headerIcon: Smalltalk ui icons smallBackIcon;
    displayBlock: [ :node | (Character value: node content asString first asciiValue + 2) asString ].
m rootNodeHolder: [ :item | 
    TreeNodeModel new
        content: (Character value: (item asString first asciiValue + 5)) asSymbol;
        icon: Smalltalk ui icons smallFullscreenIcon ].

How could I get a header in the following MultiColumnListModel?

MultiColumnListModel new
    items: {$a. $b. $c. $d. $f.};
    displayBlock: [:e | {e asString. e isVowel asString} ];
    openWithSpec.
Uko
  • 13,134
  • 6
  • 58
  • 106
user869097
  • 1,362
  • 8
  • 16

1 Answers1

0

Will this work for you?

    model := MultiColumnListModel new
    items: { {'Letter'. 'isVowel'.}. $a. $b. $c. $d. $f.};
    displayBlock: [:e | 
    e isArray 
    ifTrue:[{e first asString. e last asString} ]
    ifFalse:[
    {e asString. e isVowel asString} ]].
model 
    whenSelectionChanged:[  
        model getIndex  =  1 ifTrue:[       
        model setIndex:0].
    ];
    openWithSpec. 
Thushar G R
  • 1,017
  • 9
  • 24