Search code examples
dropdownboxgoogle-app-maker

Binding options dropdown filtering with textbox value in Google App Maker


Good day to all, I need your help to binding an dropdown in Google App Maker. I have 2 datasources, one for value and other for options and names. The problem is when I try to filter the dropbox with a textbox value. capture

in TextBox's onValueChange I put this code but it does not work.

var item = widget.parent.descendants;
app.datasources.Prycts_Cmpns.query.clearFilters();
app.models.FCTRSRCBDS.datasources.Prycts_Cmpns.query.filters.s_AliasCompany._contains=widget.value;
app.models.FCTRSRCBDS.datasources.Prycts_Cmpns.load();

the next code is the datasources options,value and names of the dropdown: capture

How i can filter this dropdown with the filter?

Thxs


Solution

  • I have a feeling, that

    1. User enters some filter in TextBox
    2. In onValueChange you call clearFilters what wipes user's input
    3. You load Prycts_Cmpns datasource with no filters

    So to fix this you can check that the TextBox is bound to app.models.FCTRSRCBDS.datasources.Prycts_Cmpns.query.filters.s_AliasCompany._contains and simplify onValueChnage event handler to this

    // at this point filter's value should be already set by binding
    app.models.FCTRSRCBDS.datasources.Prycts_Cmpns.load();