Search code examples
google-app-maker

How to access enabled property of elements present inside a list row in appmaker?


I have a list in which the listRow contains a panel inside. Then, inside the panel there are 3 text fields. I want to disable those 3 text fields through code but the problem is that I am not able to access the enabled property of those 3 text fields.

I tried the following to no avail:

var x=app.currentPage.descendants.FileList.descendants._values;

Any ideas?


Solution

  • According to the List Widget documentation, the properties table explains:

    descendants - All the children of this Layout widget recursively, identified by their names. This excludes any repeated children, such as rows in a List, cells in a Grid, Accordion, and their content.

    Therefore, using descendants will definitely NOT give you what you want. Moreover, it also explains:

    children - The direct children of this Layout widget, identified by their names.

    Here, is not specifying that it will exclude repeated children, and since each row item in a list is a repeated child, then this is the option we need to use.

    Now, invoking the children will give us a PropertyMap, so we need to iterate through each item by invoking the PropertyMap values. So you need to do this:

    var rows = app.currentPage.descendants.FileList.children._values;
    rows.forEach(function(row){
        var rPanel = row.descendants.[PanelWidgetName];
        var panelDescs = rPanel.descendants.
        panelDescs.forEach(function(desc){
            desc.enabled = true; //false
        });
    });