« Return to Thread: MATableComponent - using condition on cells

MATableComponent - using condition on cells

by cedrick beler :: Rate this Message:

Reply to Author | View in Thread

Hi

I'd like to be able to put condition on cells of my table. I want them
to be Number (float  between 0 and 1 or integer between 0 and 100).

So I changed the method buildDescriptionTable in MATableComponent (a copy of it)

buildDescriptionTable
        ^ self dataTable collect: [ :row :col :each |
                self description reference copy  "(-> return a MAStringDescription)"
                        accessor: MANullAccessor new;
                        label: row asString , '/' , col asString;
                        propertyAt: #row put: row;
                        propertyAt: #column put: col;
                        yourself ]

becomes:

buildDescriptionTable
        ^ self dataTable collect: [ :row :col :each |
                MANumberDescription new
                        accessor: (MABlockAccessor
                                read:  [ :model | (model memento cache at: (self description) )
at: row at: col ]
                                write: [ :model :object |  self halt. (model memento cache at:
(self description) )at: row at: col put: object]);
                        min: 0 max: 1;
                        label: row asString , '/' , col asString;
                        readonly: (col < row);
                        propertyAt: #row put: row;
                        propertyAt: #column put: col;
                        yourself ].

I think that instead of a NullAccessor and write:using: and readUsing:
which I removed, I can have a real accessor that can do the job. but
this doesn't really work :)

I'm sure I messed something with the memento (all table value are the
same now), so if you see something wrong in what I did, please tell
me.

Thanks,

Cédrick


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

 « Return to Thread: MATableComponent - using condition on cells

LightInTheBox - Buy quality products at wholesale price!