Quantcast
Channel: Reports & Macros
Viewing all articles
Browse latest Browse all 1118

ComboBox - initial setting, display and value doesn't match

$
0
0

Hi Community,

there's a little problem that's annoying me right now while developing a report for ARIS 9.8.
I have a dialog window, where I among others want to select a text from a ComboBox and save this into an array. And this several times in a row without leaving the dialog.
Let's assume I have the following list:
aMod[0] = "A"
aMod[1] = "B"
aMod[2] = "C"
aMod[3] = "D"

The first time I call the selection everything is fine. I see on the ComboBox the first entry "A". If I select another (e.g. "C"), the other text will be saved into the resulting array aTxt. If I don't change the selection the first entry will be saved.
The next time I call the selection I expect to see the first entry "A" again. But instead I see the former selected entry "C". I can select another (e.g. "B") and the other will be saved.
The worst case is when I call the selection once again and do not change it. The former selection is displayed "B". But the first entry "A" will be saved into aTxt. It seems as if the selection index set with setSelection() in the ComboBox does not match the displayed selection index.

I also tried to use the getValue() function instead of the getSelection(). But the behavior is the same.
The setValue() function instead of the setSelection does not work. Obviously there is no setValue() function for this type of objects.

The procedure is like this:
I press the button BNew, make my selection in the ComboBox and confirm it with the button BApply. Then the selected text is saved into a new record in aTxt.
Before pressing the BNew-button and after pressing the BApply-button the ComboBox is not enabled and not visible. It's not sure that the items of the selection list aMod are the same every time. Therefore aMod is reloaded every time the selection is activated.

function DIA_configSubDialog()
{

    var aTemplate = new Array();

    this.getPages = function()
    {
        var aMod = getMod();

        aTemplate[0] = Dialogs.createNewDialogTemplate(1170, 600, "Dialog");

        ...

        aTemplate[0].ComboBox(900, 330, 20, 20*aMod.length, aMod, "CBMod");

        ...
    }

    this.BNew_pressed = function()
    {
        var aPages = new Array();
        var aMod   = getMod();

        aPages[0].getDialogElement("CBMod").setEnabled(true);
        aPages[0].getDialogElement("CBMod").setVisible(true);

        aPages[0]  = this.dialog.getPage(0);
        aPages[0].getDialogElement("CBMod").setItems(aMod);
        aPages[0].getDialogElement("CBMod").setSelection(0);

        ...
    }

    this.BApply_pressed = function()
    {
        var aPages = new Array();
        
        aPages[0]  = this.dialog.getPage(0);

        aTxt       = createRec(aTxt, aPages);

        ...
    }

function createRec(aTxt, aPages)
{
    var aMod;
    var sMod;
    var nMod;
    var nIdx;

    aMod = aPages[0].getDialogElement("CBMod").getItems();
    nMod = aPages[0].getDialogElement("CBMod").getSelection();
    sMod = aMod[nMod];

    nIdx          = aTxt.length;
    aTxt[nIdx]    = new Array();
    aTxt[nIdx][0] = sMod;

    ...

    aPages[0].getDialogElement("CBMod").setEnabled(false);
    aPages[0].getDialogElement("CBMod").setVisible(false);

    return aTxt;
}

Can anyone help me tell me what I've done wrong?
What I want is that every time I call the selection the first item is displayed in the ComboBox and that I get the item that's selected. Completely independent of how often the selection was called and whether the selection was changed or not.

Many thanks in advance for your effort.
Greetings Holger


Viewing all articles
Browse latest Browse all 1118

Trending Articles