Date: Mon, 18 Aug 2008 16:02:55 -0400
Reply-To: Randy Herbison <RandyHerbison@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Randy Herbison <RandyHerbison@WESTAT.COM>
Subject: Re: SAS/AF: Cell Editor Control: Prevent Alteration of Cell
Contents
In-Reply-To: <200808181932.m7IGKO4L002246@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"
I actually added the "who" attribute to the frame when I tested the
idea. The model SCL compiled with this statement: if
_self_.frameID.who='E' then _self_.who=' ';
Here's my tested code:
*** editor SCL ***;
dcl char(1) value;
dcl object objectID;
init:
radiobox.selectedItem=value;
return;
term:
value=radiobox.selectedItem;
objectID.ownerID.frameID.who='E';
objectID=objectID;
return;
*** model SCL ***;
init:
sex2=sex;
return;
sex:
if _self_.frameID.who='E' then _self_.who=' ';
else sex=sex2;
return;
I suggested adding the attribute to the data model thinking it would be
a better choice than the frame, but the SCL compiler recognizes that the
attribute isn't part of the class definition.
You should be able to either (1) add the "who" attribute to the frame
instead of the data model and continue to use dot notation in the model
SCL or (2) use CALL SEND to get the data model's instance attribute
value (who) from within the model SCL.
-Randy
-----Original Message-----
From: Paul Walker [mailto:walker.627@OSU.EDU]
Sent: Monday, August 18, 2008 3:33 PM
To: SAS-L@LISTSERV.UGA.EDU; Randy Herbison
Subject: Re: SAS/AF: Cell Editor Control: Prevent Alteration of Cell
Contents
This is clever.
I am struggling with the implementation, though. I get the error
message:
ERROR: [Line 60] Unknown attribute WhoEdited for
SASHELP.CLASSES.SASDATASET_C.CLASS.
ERROR: [Line 61] Unknown attribute WhoEdited for
SASHELP.CLASSES.SASDATASET_C.CLASS.
ERROR: Compile error(s) detected. No code generated.
This is even after I added the attribute WhoEdited to the data model.
60 if upcase(_self_.WhoEdited) = 'EDITOR' then do;
61 _self_.WhoEdited = ' ';
end;
else do;
_self_._setColumnText( RunColName, RunValue );
end;
Below is the whole program (it is unfortunate how SCL editor pads the
text so much!!!) Any ideas? I double checked that the attribute was
added to the model. I also checked if I declared the model explicitly
anywhere rather than as type object. As far as I can tell it is not
really declared anywhere since it was simply created at build time.
DFINIT:
dcl object
viewerO ;
dcl char( 100)
rowDescription ;
dcl char( 32)
RunColName ;
dcl char(1000)
RunValue ;
dcl char( 41)
dsModel0Table ;
dcl char( 20)
command ;
dcl list rowL=
{} ;
dcl list colL=
{} ;
dcl list dsCols=
{} ;
dcl num
curRowNum ;
dcl num
colNum ;
return;
INIT:
* retrieve the viewer
object;
viewerO = getnitemn( getnitemo( getniteml(
_self_ , '_ATTRS_' ) , 'delegateId' ) , 'VIEWERID' );
* Get list co-ordinates of active
cell;
viewerO._getActiveCell( rowL ,
colL );
* Get the column number from the column list co-
ordinates;
colNum = getitemn( colL ,
1 );
* Get the row
number;
_self_._getCurrentRowNumber(
curRowNum );
* Get the column
name;
colName = getitemc( dsCols ,
colNum ) ;
* Get the header field
(s);
_self_._getColumnText( 'rowDescription',
rowDescription );
* Get the initial run value before
editing;
_self_._getColumnText( RunColName,
RunValue );
return;
MAIN:
* Run the object label of the viewer object (this is the part which
updates the preview pane);
viewerO._ObjectLabel
();
* Only allow editing done thru the cell editor
control;
if upcase(_self_.WhoEdited) = 'EDITOR' then
do;
_self_.WhoEdited
= ' ';
end;
else
do;
_self_._setColumnText( RunColName,
RunValue );
end;
return;
TERM:
return;
DFTERM:
return;
On Mon, 18 Aug 2008 13:58:59 -0400, Randy Herbison
<RandyHerbison@WESTAT.COM> wrote:
>Paul,
>
>Use an object attribute to track who (which control) edited the value:
>
>1. Add a character attribute (who) to the SAS dataset model. 2. Set
>the attribute value to a nonmissing value when the custom cell editor
>frame changes the cell value. 3. Use the model SCL INIT label to make
>a copy of the initial cell value.
>4. In the column's object label, check who edited the value. If it
was
>the custom editor frame, set the "who" attribute to missing. If not,
>restore the copied cell value.
>
>*** custom editor SCL ***;
>dcl char(1) value;
>dcl object objectID;
>
>init:
>radiobox.selectedItem=value;
>return;
>
>term:
>value=radiobox.selectedItem;
>
>* Set the data model's custom "who" attribute;
>objectID.ownerID.who='E';
>
>objectID=objectID;
>return;
>
>*** model SCL ***;
>init:
>sex2=sex;
>return;
>
>sex:
>if _self_.who='E' then _self_.who=' ';
>else sex=sex2;
>return;
>
>-Randy
>
>
>
>-----Original Message-----
>From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
>Paul Walker
>Sent: Monday, August 18, 2008 12:37 PM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: SAS/AF: Cell Editor Control: Prevent Alteration of Cell
>Contents
>
>
>>Are you trying to prevent the user from entering invalid values?
>>Informats and/or model SCL can be used to prevent invalid values.
>
>Maybe I used the wrong terminology... I am using a custom cell editor
>(an SCl program and/or frame I developed) which is invoked by clicking
>the elipsis within the cell. The custom cell editor brings up a
>complex frame where the user selects a row in a table viewer and then a
>delimited list of values (e.g. description=,name=,path=) is returned to
>the cell editor, but then I use a format to display only the
>description= portion. It's too complex for the user to be simply
>typing any values in the cell on their own, so I want to prevent that.
>
>Maybe a simpler question to start would be, how can I prevent the user
>from going in and deleting the contents of a cell? I want them to have
>to click on the elipsis and in the cell editor frame that pops up, they
>will have the option to "clear" the cell. In other words, deleting the
>contents of the cell is OK if done through the cell editor frame (where
>I can check if it is OK to clear or not) but not by clicking in the
>cell and hitting the delete button. If I programmed some model SCL
>(which I already found acts funny in the presence of cell editors) to
>prevent clearing the cell, I am not sure how to make it not apply to
>the cell editor value. I was hoping there was something simple and I
>wouldn't have to deal with the interaction of the model SCL and the
>cell editor.
>
>- Paul