Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

How to reduce entries of a listfield

Avatar

Level 2

Hi there,

i have a listfield with a lot of entrys. Now i want my user to type in a textfield a searchword, e.g. "a" so all entries in the list, that doesnt start with an "a" will be removed out of it.

(there will be a lot of entries in the list, which makes it nearly impossible to scroll through all of them).

Is this possible?

i allready tried something like this in the changeEvent of a textfield:

var temp1 = "";
var eingabe1 = this.rawValue;
var removeItem = false;
for (i=0 ; i< xfa.resolveNode("Formular1.#subform[0].list1").length ; i++){
    temp1 = temp1 + xfa.resolveNode("Formular1.#subform[0].list1").getDisplayItem(i) + "\n";
    for(j = 0; j < this.rawValue.length ; j++){
            if(temp1.charAt(j) != eingabe1.charAt(j)) {
                //Formular1.#subform[0].list1.deleteItem(2);
                app.alert(eingabe1);
            }
    }
}

but the debugger tells me:

this.rawValue has no properties

1 Reply

Avatar

Level 2

ok, i managed it by doing this:

var temp1 = "";
var eingabe1 = this.rawValue;
var removeItem = false;
for (i=0 ; i< xfa.resolveNode("Formular1.#subform[0].list1").length ; i++){
    temp1 = xfa.resolveNode("Formular1.#subform[0].list1").getDisplayItem(i) + "\n";
    for(j = 0; j < this.rawValue.length ; j++){
            if(temp1.charAt(j) != eingabe1.charAt(j)) {
                xfa.resolveNode("Formular1.#subform[0].list1").deleteItem(i);
                i = 0;
                break;
            }
    }
}

but its working only in the exit event. the change event seems to be fireing before the value of the textfield is assigned the inputvalue. is there any possibilty i can delete the items at "runtime"?