Hi All ,
This is my first email to group......however i havenot read the complete mail.
just scanned....
Bu what I & my friend Anish can say is ..................
If you dont want to display all the values of a specific base enum
in
certain forms, is it necessary to delete some values from a BaseEnum at
runtime? Instead of deleting we can hide the values from the user.
1 Hiding the value from the user on a specific form
Control which present the enumtype should have AutoDeclaration (yes)
Try this piece of code
Control_name.delete(Name of the element);
If we really want to delete the values of a baseenum on run time Use the
class SysDictEnum
2 Deleting the enum value on Run time (dynamically)
SysDictEnum = new SysDictEnum(enum_Id); //initialization
Sysdictenum.treeNode().AOTfindChild("Name of the
element").AOTdelete(); //deleting the element from the Enum
SysDictEnum.treeNode().AOTcompile(1); //compile
SysDictEnum.treeNode().AOTsave(); //Saving the baseenum
Pls chk out the link for further info:
microsoft.public.axapta.programming
Sailendran Rajan
axaeffect <[EMAIL PROTECTED]> wrote: Hi all,
this disscusion already old, but does anyone already found the
solution yet? 'cause this's also my problem right now.. :)
Daniel's code seems fine to me, b'cause when I debug it, the final
result is the value of the original enum, not the deleted one.
But the overwrite method "Enter" which delete the unwanted enum
produce an unbalance program, after I select the enum combo, the
form refresh all the time..
thanks,
ton
--- In [email protected], "brotherjason82"
<[EMAIL PROTECTED]> wrote:
>
> Hi Daniel, your problem still exists. the thing is, axapta stores
the
> selection using the enumvalue (integer) within the record level.
you
> can look at the table browser and look at the saved record. what
you
> have info-ed is just the text selection of the enum. not the
> enumvalue. try infoing this.selection() and see the difference.
> cheers. i am also currently playing with hidding enum list. but
have
> not found a good way. will experiment with the below suggested
options
> by lenard as well.
>
> --- In [email protected], daniel lim
> <daniellim_yh@> wrote:
> >
> > hi Lennart,
> >
> > i use something like this:
> >
> > in combox:enter:
> >
> > public void enter()
> > {
> > super();
> > //EnumABC has element A, B,C
> > this.delete(enum2str(EnumABC::B));
> > }
> >
> > in combobox:modified:
> >
> > public boolean modified()
> > {
> > EnumABC _EnumABC;
> > boolean ret;
> >
> > ret = super();
> >
> > _EnumABC = str2enum(_EnumABC, this.getEditText());
> >
> > info(strfmt('%1',str2enum(_EnumABC,this.getEditText())));
> > info(strfmt('this is %1',_EnumABC));
> > return ret;
> > }
> >
> > in this example, i remove element B, at clicked method, it
return
> correct value for A and C as well.
> >
> > any problem with this code?is this recommended? pls advice and
thx.
> >
> >
> > daniel
> >
> > Lennart Conrad <lennartc@> wrote:
> > If you use this approach (override enter), you will remove the
enum
> > value, but the remaining values in the enum will have their
values
> > shifted:
> > E.g
> > You have the enum (Quarter 1 = 1, Quarter 2 = 2, Quarter 3 = 3
Quarter
> > 4=4)
> > If you remove, Quarter 3, you will get 3 returned if you select
Quarter
> > 4. This is most likely NOT what you wan't.
> >
> > I know of two approaches to this problem that works:
> >
> > Option 1.
> > -Create a new enum, that contains the elements you want to
display and
> > have the same values as the original enum elements
> > e.g Quarter 1 = 1, Quarter 2 = 2, Quarter 4=4), if you wan't to
hide
> > quarter 3.
> > -create an edit method on the appropriate table that returns the
new
> > enum. It could look something like this:
> > edit QuarterTypeNoQuarter3 QuarterTypeNoQuarter3boolean _set,
> > QuarterTypeNoQuarter3 _QuarterTypeNoQuarter3)
> > {
> > QuarterTypeNoQuarter3 QuarterTypeNoQuarter3;
> > ;
> >
> > if (_set)
> > {
> > this.QuarterType = any2int(_QuarterTypeNoQuarter3);
> >
> > if (!this.validateField(fieldnum(YourTable,
QuarterType)))
> > {
> > this.QuarterType = this.orig().QuarterType;
> > }
> > }
> >
> > QuarterTypeNoQuarter3= any2int(this.QuarterType);
> >
> > return QuarterTypeNoQuarter3;
> > }
> > - drag the edit method to your form, instead of the table field
> > - You might want to exclude any records that have the hidden
enum value
> > so the dont appear to have a blank value
> >
> > Option 2: This is more complex, but can be used if you want to
disable
> > different enums, e.g based on a caller.
> > - create an edit method that returns the enum
> > In pseudo code, this is what you have to do:
> > - Loop through all the values in the dictenum
> > - if the value is to be excluded you must map all the
remaining
> > enumvalues to the right value so they do not shift value, e.g
Using a
> > Map
> > - else if the value is not excluded, but have been
adjusted in
> > the step above, you must also adjust the forthcoming
values
> > - else the mapping is ok
> >
> > - based on the input to the method, you can lookup the correct
value in
> > your map and return it.
> >
> > I have some none-production code, that I can provide, if you
need it for
> > option 2, but I recommend option 1, if possible
> >
> > /Lennart Conrad
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Vikas
Garg
> > Sent: 13. februar 2006 11:06
> > To: [email protected]
> > Subject: RE: [development-axapta] making enum element invisible
> >
> > Hi Daniel,
> > Override "enter method" of the control that is mapped with enum
type
> > object... write code after super method as follows:
> >
> > this.delete(enum2str(enum::element));
> > here element is the one that u don't want user to see while
selection of
> > enum type...
> > I hope this will solve your problem..
> >
> > Regards
> >
> > Vikas Garg
> > (Technical Consultant)
> > EuroInfo Systems Pvt. Ltd.
> > Sector 2, Noida.
> > Direct No - +91-9911213322
> > Office No - +91-120-2520414 ext. 213
> >
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[EMAIL PROTECTED] On Behalf Of
daniellim_yh
> > Sent: Saturday, February 11, 2006 6:29 AM
> > To: [email protected]
> > Subject: [development-axapta] making enum element invisible
> >
> > hi all,
> >
> > how we can make enum element invisible?for example for usage in
form?
> >
> > if i have an enum of element A,B and C, but in form i only would
like
> > to display A and B for user selection, can i make C invisible
inside
> > the form?
> >
> > thx in advance.
> >
> > daniel
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > SPONSORED LINKS
> > Computer part Programming languages Microsoft
axapta
> Support exchange
> >
> > ---------------------------------
> > YAHOO! GROUPS LINKS
> >
> >
> > Visit your group "development-axapta" on the web.
> >
> > To unsubscribe from this group, send an email to:
> > [EMAIL PROTECTED]
> >
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service.
> >
> >
> > ---------------------------------
> >
> >
> >
> >
> >
> > ---------------------------------
> > Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, &
> more on new and used cars.
> >
> > [Non-text portions of this message have been removed]
> >
>
---------------------------------
Everyone is raving about the all-new Yahoo! Mail beta.
[Non-text portions of this message have been removed]