Rendering a command column as a drop down

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Rendering a command column as a drop down

Rogier Schaaf
Hi,

I have a QCBMagritteReport (a subclass of MAReport) with a command column with options to perform on each row:

addColumn:
(MACommandColumn new
addCommandOn: self selector: #edit: text: 'Edit';
addCommandOn: self selector: #delete: text: 'Delete';
addCommandOn: self selector: #validate: text: 'Check';
yourself)

This works well, however I would like to see a Bootstrap drop down button as opposed to individual links being shown. I've experimented with QCCommandColumn but without success (it needs something in its component instance variable but I'm clueless as to what).

Is there a specialised renderer for this I can use or should I implement my own?

Thanks for reading.

Roger

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Rendering a command column as a drop down

Stephan Eggermont-3
Hi Rogier,

Please feel free to add something for this to QCMagritte

 >I've experimented with QCCommandColumn but without
 >success (it needs something in its component instance
 >variable but I'm clueless as to what).

QCCommandColumn>>execute: aBlock with: aRow
     aBlock isSymbol ifTrue: [ ^aRow perform: aBlock ].
     ^aBlock cull: aRow cull: self component

A command may want to have access to both the row it operates
on and the report, or the component containing the report

QCToManyReport>>buildCommandColumn
     | retVal |
     retVal := (QCCommandColumn on: self) setReport: self report.
     self addDefaultCommandsTo: retVal.
     self addDescriptionCommandsTo: retVal.
     self addOrderingCommandsTo: retVal.
     ^ retVal

Stephan
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Rendering a command column as a drop down

Rogier Schaaf
Hi Stephan,

I'm just starting out with Magritte and QCMagritte and combined they're quite a substantial code base to get your head around. Before doing an attempt at something useful I wanted to get it working for my specific situation, so I subclassed MACommandColumn and re-implemented renderCellLinkContent:on: like so:

renderCellLinkContent: anObject on: html

html tbsButtonGroup: [
html tbsDropdownButton
beDefault;
beExtraSmall;
with: [
html text: 'Commands ';
tbsCaret
].
html tbsDropdownMenu: [ 
self commands
do: [ :each |
each value = 'divider'
ifTrue: [ html tbsDivider ]
ifFalse: [
html tbsDropdownMenuItem: [
html anchor
callback: [ each key value: anObject ];
with: each value ]
]
]
]
]

I used the Twitter Bootstrap implementation by Torsten Bergmann to perform the rendering. Again, not sure if this is within the scope of QCMagritte.

Cheers,

Rogier

On 3 June 2015 at 21:45, Stephan Eggermont <[hidden email]> wrote:
Hi Rogier,

Please feel free to add something for this to QCMagritte

>I've experimented with QCCommandColumn but without
>success (it needs something in its component instance
>variable but I'm clueless as to what).

QCCommandColumn>>execute: aBlock with: aRow
    aBlock isSymbol ifTrue: [ ^aRow perform: aBlock ].
    ^aBlock cull: aRow cull: self component

A command may want to have access to both the row it operates
on and the report, or the component containing the report

QCToManyReport>>buildCommandColumn
    | retVal |
    retVal := (QCCommandColumn on: self) setReport: self report.
    self addDefaultCommandsTo: retVal.
    self addDescriptionCommandsTo: retVal.
    self addOrderingCommandsTo: retVal.
    ^ retVal

Stephan
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Rendering a command column as a drop down

Stephan Eggermont-3


On 04/06/15 00:03, Rogier Schaaf wrote:
Hi Stephan,

I'm just starting out with Magritte and QCMagritte and combined they're quite a substantial code base to get your head around. Before doing an attempt at something useful I wanted to get it working for my specific situation, so I subclassed MACommandColumn and re-implemented renderCellLinkContent:on: like so:

renderCellLinkContent: anObject on: html

html tbsButtonGroup: [
html tbsDropdownButton
beDefault;
beExtraSmall;
with: [
html text: 'Commands ';
tbsCaret
].
html tbsDropdownMenu: [ 
self commands
do: [ :each |
each value = 'divider'
ifTrue: [ html tbsDivider ]
ifFalse: [
html tbsDropdownMenuItem: [
html anchor
callback: [ each key value: anObject ];
with: each value ]
]
]
]
]

I used the Twitter Bootstrap implementation by Torsten Bergmann to perform the rendering. Again, not sure if this is within the scope of QCMagritte.

Sounds fine. It's just like what we do more often in QC-Magritte-Bootstrap. Might fit in
QC-Magritte-Bootstrap-Component, or you might want to add an option
in QCBToManyComponent to use this style. Perhaps subclass QCCommandColumn
for this, and look at where that is used?

Stephan


Cheers,

Rogier

On 3 June 2015 at 21:45, Stephan Eggermont <[hidden email]> wrote:
Hi Rogier,

Please feel free to add something for this to QCMagritte

>I've experimented with QCCommandColumn but without
>success (it needs something in its component instance
>variable but I'm clueless as to what).

QCCommandColumn>>execute: aBlock with: aRow
    aBlock isSymbol ifTrue: [ ^aRow perform: aBlock ].
    ^aBlock cull: aRow cull: self component

A command may want to have access to both the row it operates
on and the report, or the component containing the report

QCToManyReport>>buildCommandColumn
    | retVal |
    retVal := (QCCommandColumn on: self) setReport: self report.
    self addDefaultCommandsTo: retVal.
    self addDescriptionCommandsTo: retVal.
    self addOrderingCommandsTo: retVal.
    ^ retVal

Stephan
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki



_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki