Topic
  • 17 replies
  • Latest Post - ‏2014-07-26T13:10:42Z by KBSri
KBSri
KBSri
104 Posts

Pinned topic Copying the value entered inside the TEXTBOX to dropdown available

‏2014-05-30T11:23:43Z | doors;dxl;

Hello,

There is strange scenario in which i need to copy the text entered inside the TEXTBOX to the drop down available.

The drop down is already available but needs to add the value entered in the text box and then based on that manipulations is to be done.

Kindly help.

Thanks.

Updated on 2014-05-30T11:28:49Z at 2014-05-30T11:28:49Z by KBSri
  • llandale
    llandale
    3035 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-05-30T16:05:29Z  

    You can modify the options in a "choice" or "list" box after the dialog is "realized".  You can "empty" the entire list, or "delete" or "insert" individual line items.  See DXL manual "Common Element Operations", and practice with a test box.

    Seems to me that an EOL would cause some havok as a "choice" option, as would rich text.  I therefore suspect that the user should enter the new option into a "field" rather than a "text box", since "field" doesn't allow those tricky things.  Anyway, you could have a button next to the text/field saying "insert into choice", you could also assign a callback to the text/field that gets fired when the user hits "enter".

    -Louie

    The dialog "realize" positions the choice/list vis-a-vis other dialog elements (such as buttons).  Subsequent modifications to the contents does not alter the dialog layout.

  • KBSri
    KBSri
    104 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-06-01T18:26:52Z  
    • llandale
    • ‏2014-05-30T16:05:29Z

    You can modify the options in a "choice" or "list" box after the dialog is "realized".  You can "empty" the entire list, or "delete" or "insert" individual line items.  See DXL manual "Common Element Operations", and practice with a test box.

    Seems to me that an EOL would cause some havok as a "choice" option, as would rich text.  I therefore suspect that the user should enter the new option into a "field" rather than a "text box", since "field" doesn't allow those tricky things.  Anyway, you could have a button next to the text/field saying "insert into choice", you could also assign a callback to the text/field that gets fired when the user hits "enter".

    -Louie

    The dialog "realize" positions the choice/list vis-a-vis other dialog elements (such as buttons).  Subsequent modifications to the contents does not alter the dialog layout.

    Louie,

    Thanks a lot. Any help in DXL scripting to execute this. Just to get started with this.

    I am not an expert so I need help on that please.

  • Tony_Goodman
    Tony_Goodman
    271 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-06-02T15:14:57Z  
    • KBSri
    • ‏2014-06-01T18:26:52Z

    Louie,

    Thanks a lot. Any help in DXL scripting to execute this. Just to get started with this.

    I am not an expert so I need help on that please.

    The choice DBE can be made editable allowing the user to enter their own text.

    Here is an example from the help edited to do this.

    DB reqBox = create "Edit Requirement"
    string importance[] = {"Vital", "Useful",
                             "Convenient", "Useless"}
    DBE reqImport = choice(reqBox, "Importance: ",
                     importance, 2, 30, true)
    void accept(DB reqBox) {
        string s = get reqImport
        print s
    } // accept
    ok(reqBox, "Accept", accept)
    show reqBox

     

    Note that this means you have to use the string version of get() rather than the integer version.

    Hope that helps

    Tony

     

    Updated on 2014-06-02T15:15:28Z at 2014-06-02T15:15:28Z by Tony_Goodman
  • KBSri
    KBSri
    104 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-06-03T09:39:18Z  

    The choice DBE can be made editable allowing the user to enter their own text.

    Here is an example from the help edited to do this.

    DB reqBox = create "Edit Requirement"
    string importance[] = {"Vital", "Useful",
                             "Convenient", "Useless"}
    DBE reqImport = choice(reqBox, "Importance: ",
                     importance, 2, 30, true)
    void accept(DB reqBox) {
        string s = get reqImport
        print s
    } // accept
    ok(reqBox, "Accept", accept)
    show reqBox

     

    Note that this means you have to use the string version of get() rather than the integer version.

    Hope that helps

    Tony

     

    Thank a lot Tony. In case if need to enter only the TEXT with the capital letters.How can I do it?

  • llandale
    llandale
    3035 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-06-03T18:50:07Z  
    • KBSri
    • ‏2014-06-03T09:39:18Z

    Thank a lot Tony. In case if need to enter only the TEXT with the capital letters.How can I do it?

    Not sure this is what you asked, but you can convert a string to upper (or lower) characters:

    • string Upper = upper(s)
    • string Lower = lower(s)

    -Louie

  • KBSri
    KBSri
    104 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-06-04T09:31:53Z  
    • llandale
    • ‏2014-06-03T18:50:07Z

    Not sure this is what you asked, but you can convert a string to upper (or lower) characters:

    • string Upper = upper(s)
    • string Lower = lower(s)

    -Louie

    Hello Louie.

    I need to add a new ENUM value for the specific attribute from the GUI(ie.drop down) and do the manipulations.

    Please help.

  • llandale
    llandale
    3035 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-06-04T13:24:09Z  
    • KBSri
    • ‏2014-06-04T09:31:53Z

    Hello Louie.

    I need to add a new ENUM value for the specific attribute from the GUI(ie.drop down) and do the manipulations.

    Please help.

    Wow.  Sure seemed like you were asking for help on a drop down on a dialog box.  This last post makes it seem like you want to prompt the Module admin for a new enumerated value, and add that value to an enumerated attribute TYPE.  If so, that is very difficult.  The basic DXL function to manipulate enumerations is the "modify (attribute type)" command in the DXL manual, in section "Attribute type manipulation"

    • AttrType modify(AttrType type, string newName [, string codes[ ], int values[ ], int colors[ ], string descs[ ] [, int arrMaps[ ],]]  string &errmess)

    There is also an undocumented version that uses Skip lists instead of arrays, but I don't quite get that.

    This version requires you to declare a set of parellel arrays representing the new set of enumerations.  So if you want to change the list of 5 enumerations into a set of 7, then you declare arrays at size 7, populate them, and then call "modify". 

    The key to this is the "mapping" array, where you define which new enumeration "maps" to which old enumeration.  So if you want to change "Low" and "High" into "None", "Medium", and "High" it behooves you to say that new enum #2 "High" maps to old enum #1, which is also "High".  So the mapping array would look like: {0, -1, 1}.  "None" maps to "Low", "Medium" maps to nothing, "High" maps to "High".  You use the "mapping" to make sure you preserve existing values; so an object that currently says "High" still says "High" and an object that currently says "Low" says "None" after you modify.

    I think it very difficult to build a dialog that gives the user the freedom of moving things around like that.  Now if your dialog simply wants to add a new enurmation to the bottom of an existing set, then I think it is achievable.  You get the AttrType, get its "size", declare arrays at size "Size+1", populate the 1st "Size" values in the arrays, mapping is i=i, add the new one to the last array value, and "modify" the AttrType.

    -Louie

    I will say that I've tried but not succeeded in writing DXL to modify enumerated values of attributes in multiple modules.

  • KBSri
    KBSri
    104 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-06-06T09:22:06Z  
    This reply was deleted by KBSri 2014-07-02T14:38:24Z.

    Please help me out.

  • llandale
    llandale
    3035 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-06-06T20:46:53Z  
    This reply was deleted by KBSri 2014-07-02T14:38:24Z.

    Runing out of time so let me scribble part of this.

    void  AddEnum(Module mod, string NameEnumType, string NewEnumValue)
    {  // Add the NewEnumValue to the bottom of the list of Enumerations in the
         // named Enumerated Type in the Module
       AttrType at = find(mod, NameEnumType)
       if (null at) then display some error and return
       if(basType is not "enuermated) ditto
       int SizeOld = at.size
       int SizeNew = SizeOld+1
       string Codes[SizeNew], other string vectors
       int Values[SizeNew], Mapping[SizeNew], other int Vectors
       int i
       for (i=0; i<SizeOld; i++)
       {  Codes[i] = at.codes[i]
          Values[i] = at.values[i]
          other vectors like Colors
         Mapping[i] = i    // New Enum maps to identical old enum
      }
                       // Populate the single new Enum
      Codes[SizeNew-1] = NewEnumValue
      Values[SizeNew-1] = 0
       Mapping[SizeNew-1] = -1    // New Enum doesn't map to any old one
       atNew = modify(at,various vectors, Mapping, ErrMess)
    }

    There is a problem with the "Colors" vector, but I don't recall what it is.

    -Louie

    Updated on 2014-06-06T20:48:16Z at 2014-06-06T20:48:16Z by llandale
  • llandale
    llandale
    3035 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-07-03T15:14:02Z  
    This reply was deleted by KBSri 2014-07-03T15:13:47Z.

    It would make it a lot easier if you would say what is going wrong.  Debugging for "an issue" in 1700 lines of code is difficult.

    But I do see this: You have a conceptual problem distinguishing Attribute "Values" from Attribute "Definitions" from Attribute "Types".

    Values: An object can be given a value for an attribute; e.g. setting the "Object Text" for an object.  The normal module GUI shows objects as rows and typically attributes as columns, when you edit a cell you are giving that object a value for that attribute.  Objects can have attribute values, so can Modules and Links. (Not Projects nor Folders).  

    Definition. This makes an attribute available in a module.  the Definition constrains..

    [1]  What kind of data can be put in the attribute, Text, String, Integer, Boolean etc.  This constraint is called the attribute "Type".
    [2]  Whether the attribute applies to Objects, the Module, or both.  Notice that system attribute "Prefix" can only be set for the Module (an Object cannot have its own "Prefix"), and system attribute "Object Text" can be set only for Objects (the Module cannot have its own "Object Text").

    Type. List of available attribute value contraint types.  Notice that there are standard types already defined, "Text", "String", "Integer" et tal.  When you create an attribute Definition, you must assign it a Type.  A Type can be used by more than one definition, e.g. Last Modified On and Created On are both of type "Date".

    Imagine definiing a Type called "Percent" that has a base type of "Integer" but is contrained to values of 0-100.  Then define a Definition "Completion Percent" based on type "Percent".

    The vast majority of user-defined "Types" are enumerations.  Lets say you define a type "Severity" with enumerations "None", "Low", "Medium", "High", and "Critical".  You can then define two attribute Definitions "Risk Development Severity" and "Risk Legal Severity", which apply to Objects.  You can then put these two Defs in a view, and assign values for them to all the objects.

    Changing a "Value" in DXL looks like:     o.NameAttr = SomeValue

    Changing a "Definition" in DXL looks like: AttrDef ad = find(mod, NameAttr).  Make some changes to ad.

    Changing a "Type" in DXL looks like: AttrDef ad = find(mod, NameAttr); AttrType = ad.type; make some changes to at.

    Read more in the User Manual.

    Now back to your problem.

    [1] Line 1026 in function addValueToTestAttr, you are changing the value of the module-attribute.  That only makes sense of the attribute is defined for modules; and in any case does NOT change the list of enumerations.

    • m.sAttrName=m.sAttrName "\n" sNewValue

    [2]  Line 424 in function getAttributesValues, you are retrieving the value of the module-attribute; which only makes sense of the attribute is defined for modules; and in any case does NOT give you the list of available enumerations.

    • attrValues=m.attrName

    It is difficult to do, but these two lines of code need to be changed to something like I said above, leading to the "modify(ad,xx)" command.

    -Louie

    In my opinion, based partly on my ignorance of what you are doing, is that you do NOT need a separate script to add an enumeration to a single attribute in a single module.  It is easier just to let the user do it via the GUI.

  • KBSri
    KBSri
    104 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-07-03T15:29:29Z  
    • llandale
    • ‏2014-07-03T15:14:02Z

    It would make it a lot easier if you would say what is going wrong.  Debugging for "an issue" in 1700 lines of code is difficult.

    But I do see this: You have a conceptual problem distinguishing Attribute "Values" from Attribute "Definitions" from Attribute "Types".

    Values: An object can be given a value for an attribute; e.g. setting the "Object Text" for an object.  The normal module GUI shows objects as rows and typically attributes as columns, when you edit a cell you are giving that object a value for that attribute.  Objects can have attribute values, so can Modules and Links. (Not Projects nor Folders).  

    Definition. This makes an attribute available in a module.  the Definition constrains..

    [1]  What kind of data can be put in the attribute, Text, String, Integer, Boolean etc.  This constraint is called the attribute "Type".
    [2]  Whether the attribute applies to Objects, the Module, or both.  Notice that system attribute "Prefix" can only be set for the Module (an Object cannot have its own "Prefix"), and system attribute "Object Text" can be set only for Objects (the Module cannot have its own "Object Text").

    Type. List of available attribute value contraint types.  Notice that there are standard types already defined, "Text", "String", "Integer" et tal.  When you create an attribute Definition, you must assign it a Type.  A Type can be used by more than one definition, e.g. Last Modified On and Created On are both of type "Date".

    Imagine definiing a Type called "Percent" that has a base type of "Integer" but is contrained to values of 0-100.  Then define a Definition "Completion Percent" based on type "Percent".

    The vast majority of user-defined "Types" are enumerations.  Lets say you define a type "Severity" with enumerations "None", "Low", "Medium", "High", and "Critical".  You can then define two attribute Definitions "Risk Development Severity" and "Risk Legal Severity", which apply to Objects.  You can then put these two Defs in a view, and assign values for them to all the objects.

    Changing a "Value" in DXL looks like:     o.NameAttr = SomeValue

    Changing a "Definition" in DXL looks like: AttrDef ad = find(mod, NameAttr).  Make some changes to ad.

    Changing a "Type" in DXL looks like: AttrDef ad = find(mod, NameAttr); AttrType = ad.type; make some changes to at.

    Read more in the User Manual.

    Now back to your problem.

    [1] Line 1026 in function addValueToTestAttr, you are changing the value of the module-attribute.  That only makes sense of the attribute is defined for modules; and in any case does NOT change the list of enumerations.

    • m.sAttrName=m.sAttrName "\n" sNewValue

    [2]  Line 424 in function getAttributesValues, you are retrieving the value of the module-attribute; which only makes sense of the attribute is defined for modules; and in any case does NOT give you the list of available enumerations.

    • attrValues=m.attrName

    It is difficult to do, but these two lines of code need to be changed to something like I said above, leading to the "modify(ad,xx)" command.

    -Louie

    In my opinion, based partly on my ignorance of what you are doing, is that you do NOT need a separate script to add an enumeration to a single attribute in a single module.  It is easier just to let the user do it via the GUI.

    Thanks Louie. I have updated the latest code below. Please help me out.

    Updated on 2014-07-03T15:31:08Z at 2014-07-03T15:31:08Z by KBSri
  • llandale
    llandale
    3035 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-07-03T16:02:40Z  
    This reply was deleted by KBSri 2014-07-26T13:06:04Z.

    You don't say what is happening wrong.  You don't seem to take the suggestions.  You do seem to be asking to add a bunch of functionality to some code.  I think this is beyond the scope of the forum; we don't write big scripts and give them away here.

    -Louie

  • KBSri
    KBSri
    104 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-07-03T18:02:33Z  
    • llandale
    • ‏2014-07-03T16:02:40Z

    You don't say what is happening wrong.  You don't seem to take the suggestions.  You do seem to be asking to add a bunch of functionality to some code.  I think this is beyond the scope of the forum; we don't write big scripts and give them away here.

    -Louie

    No Mr. Louie...I have always followed your suggestions. Your suggestions are invaluable , believe me I have always followed.

    I am not asking to add big bunch of code at all, I just need to add the new value entered in the DROP DOWN LIST to be added to the attribute.

    Sometimes I do not understand big functionality but after your suggestions you have made me to code better.

    Thanks.

  • llandale
    llandale
    3035 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-07-03T18:10:23Z  
    • KBSri
    • ‏2014-07-03T18:02:33Z

    No Mr. Louie...I have always followed your suggestions. Your suggestions are invaluable , believe me I have always followed.

    I am not asking to add big bunch of code at all, I just need to add the new value entered in the DROP DOWN LIST to be added to the attribute.

    Sometimes I do not understand big functionality but after your suggestions you have made me to code better.

    Thanks.

    You have enough samples to at least get going with it.  This forum really isn't about someone else writing your code for you, its for us to help you doing so.  I'm not going to debug a 1000 line program and I'm not going add a bunch of functionality to it.

    In this particular case, just have the person add the enum manually.  Adjusting Enums is difficult.

    -Louie

  • KBSri
    KBSri
    104 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-07-07T15:17:08Z  
    This reply was deleted by KBSri 2014-07-26T13:07:59Z.

    Hello Louie/All,

    I added something the below function like this. But what I want is to add the entered name in the DROP down list box to be added in the attribute PROJECT RELEVANCY.

    Adding the following function:

    void  AddEnum(Module mod, string NameEnumType, string NewEnumValue)
    {  // Add the NewEnumValue to the bottom of the list of Enumerations in the
         // named Enumerated Type in the Module
       AttrType at = find(mod, NameEnumType)
       if (null at) then display some error and return
       if(basType is not "enuermated) ditto
       int SizeOld = at.size
       int SizeNew = SizeOld+1
       string Codes[SizeNew], other string vectors
       int Values[SizeNew], Mapping[SizeNew], other int Vectors
       int i
       for (i=0; i<SizeOld; i++)
       {  Codes[i] = at.codes[i]
          Values[i] = at.values[i]
          other vectors like Colors
         Mapping[i] = i    // New Enum maps to identical old enum
      }
                       // Populate the single new Enum
      Codes[SizeNew-1] = NewEnumValue
      Values[SizeNew-1] = 0
       Mapping[SizeNew-1] = -1    // New Enum doesn't map to any old one
       atNew = modify(at,various vectors, Mapping, ErrMess)
    }

    In the Code Line: 1444 after

    I tried something like this: if(get(dbeProjectName == 1)){ AddEnum(m,sPRJTYPE,sNewValue)}

    How to add the new value entered in the DROP DOWN list box to be called to this function.

    Thanks.

  • Tony_Goodman
    Tony_Goodman
    271 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-07-08T12:40:11Z  
    • KBSri
    • ‏2014-07-07T15:17:08Z

    Hello Louie/All,

    I added something the below function like this. But what I want is to add the entered name in the DROP down list box to be added in the attribute PROJECT RELEVANCY.

    Adding the following function:

    void  AddEnum(Module mod, string NameEnumType, string NewEnumValue)
    {  // Add the NewEnumValue to the bottom of the list of Enumerations in the
         // named Enumerated Type in the Module
       AttrType at = find(mod, NameEnumType)
       if (null at) then display some error and return
       if(basType is not "enuermated) ditto
       int SizeOld = at.size
       int SizeNew = SizeOld+1
       string Codes[SizeNew], other string vectors
       int Values[SizeNew], Mapping[SizeNew], other int Vectors
       int i
       for (i=0; i<SizeOld; i++)
       {  Codes[i] = at.codes[i]
          Values[i] = at.values[i]
          other vectors like Colors
         Mapping[i] = i    // New Enum maps to identical old enum
      }
                       // Populate the single new Enum
      Codes[SizeNew-1] = NewEnumValue
      Values[SizeNew-1] = 0
       Mapping[SizeNew-1] = -1    // New Enum doesn't map to any old one
       atNew = modify(at,various vectors, Mapping, ErrMess)
    }

    In the Code Line: 1444 after

    I tried something like this: if(get(dbeProjectName == 1)){ AddEnum(m,sPRJTYPE,sNewValue)}

    How to add the new value entered in the DROP DOWN list box to be called to this function.

    Thanks.

    What you are trying to do does not make sense. The reason for enumerated attributes is to constrain what the user can select. The reason a Combo drop-down exists is also to constrain what the user can select. For this reason the edit=true parameter is rarely used.

    I NEVER edit enumerations using DXL. Why would you want to?

    Much easier to make the changes manually and then copy the updated attribute (and corresponding type) to other modules using the copyAttrsPlus script.

    If you allow users to change enumerations on the fly you are asking for trouble.

    Tony

    Updated on 2014-07-10T10:35:24Z at 2014-07-10T10:35:24Z by Tony_Goodman
  • KBSri
    KBSri
    104 Posts

    Re: Copying the value entered inside the TEXTBOX to dropdown available

    ‏2014-07-26T13:10:42Z  

    What you are trying to do does not make sense. The reason for enumerated attributes is to constrain what the user can select. The reason a Combo drop-down exists is also to constrain what the user can select. For this reason the edit=true parameter is rarely used.

    I NEVER edit enumerations using DXL. Why would you want to?

    Much easier to make the changes manually and then copy the updated attribute (and corresponding type) to other modules using the copyAttrsPlus script.

    If you allow users to change enumerations on the fly you are asking for trouble.

    Tony

    Hello Tony,

    I am able to add the new ENUM value to the attribute after your valuable suggestions.

    Is there any way to refresh DBE immediately after adding the value to drop down list to see the newly added ENUM value?