Data View is no longer returning results

I have a Data View which returns records grouped by a user id (qocID in the code). I have returned the results into a table filtered by a selection from a Select dropdown.

Here is the data-view code

<dmx-data-view id="qoc_view" dmx-bind:data="scEntries.data.entry.groupBy(qocID)" filter="($value[0].ageID == sel_agegroup.value.toNumber())"></dmx-data-view>

For testing I have entered explicit value (ex $value[0].ageID == 1 ) as well as the code above. This used to work without error, now any value entered in the filter code results in zero records returned. When I remove the filter all records display as anticipated.

I believe this is a similar issue to one I had earier ( https://community.wappler.io/dynamic-dropdowns-suddenly-returning-undefined/42095?u=lwoolsey )

So for “not testing” i.e. production what do you need to happen there? How do you need your select to filter the data store?

The filtered data is displayed in a table with the data-view as the expression.

When I couldn’t see results using the dynamic value of the Select drop-down, I hard-coded a filter just to see if I could get any returned results. Even with an explicit filter no data was returned. When I removed the filter code, all records were returned correctly

So what’s your goal, what are you trying to achieve? Also paste your select code as well.

Here is the select code:

<select id="sel_agegroup" class="form-control d-print-block" dmx-bind:options="age_view.data" optiontext="$value[0].ageGroupID+' - '+$value[0].ageDescript" optionvalue="$value[0].ageID"></select>

The goal is to restrict the displayed records to a single “age group” from within the data-view based on the drop-down selection. This was working correctly, but now it isn’t. I haven’t changed any code, but this was working as intended. I’m not certain when it quit functioning, and this site is really only used once per year.

And what is the code that was working and not any longer?

When I place ANY value in the filter zero results are returned.

My question is:

Also - are you filtering a single column in the data view?
Also - why is your select text and value like

optiontext="$value[0].ageGroupID+' - '+$value[0].ageDescript" optionvalue="$value[0].ageID"

and not:

optiontext="ageGroupID +' - '+ ageDescript" optionvalue="ageID"

There seems to be quite a few things i see that are wrong on your page. Can you post a the page code or a link to it?

<?php

    require('../dmxConnectLib/dmxConnect.php');

    $app = new \lib\App();

    $app->exec(<<<'JSON'

    {

        "steps": [

            "Connections/db",

            "SecurityProviders/validuser",

            {

                "module": "auth",

                "action": "restrict",

                "options": {"permissions":"admin","loginUrl":"../access.php","forbiddenUrl":"../profile.php","provider":"validuser"}

            }

        ]

    }

    JSON

    , TRUE);

    ?>

    <!doctype html>

    <html>

    <head>

        <script src="../dmxAppConnect/dmxAppConnect.js"></script>

        <meta charset="UTF-8">

        <title>QOC: Admin</title>

        <link rel="stylesheet" href="../css/bootstrap-icons.css" />

        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

        <link rel="stylesheet" href="../bootstrap/5/sandstone/bootstrap.min.css" />

        <meta name="robots" content="noindex,noarchive">

        <script src="../dmxAppConnect/dmxBootstrap5Navigation/dmxBootstrap5Navigation.js" defer=""></script>

        <link rel="stylesheet" href="../fontawesome5/css/all.min.css" />

        <link rel="stylesheet" href="../dmxAppConnect/dmxNotifications/dmxNotifications.css" />

        <script src="../dmxAppConnect/dmxNotifications/dmxNotifications.js" defer=""></script>

        <script src="../dmxAppConnect/dmxStateManagement/dmxStateManagement.js" defer=""></script>

        <script src="../dmxAppConnect/dmxDataTraversal/dmxDataTraversal.js" defer=""></script>

        <script src="../dmxAppConnect/dmxFormatter/dmxFormatter.js" defer=""></script>

        <link rel="stylesheet" href="../dmxAppConnect/dmxBootstrap5TableGenerator/dmxBootstrap5TableGenerator.css" />

    </head>

    <body is="dmx-app" id="index">

        <dmx-serverconnect id="scActive" url="../dmxConnect/api/defaults/activeTournament.php"></dmx-serverconnect>

        <dmx-serverconnect id="scEntries" url="../dmxConnect/api/scoring/allEntry.php" dmx-param:filter="scActive.data.activeTourney.tourneyID"></dmx-serverconnect>

        <dmx-data-view id="age_view" dmx-bind:data="scEntries.data.entry.groupBy(`ageID`)"></dmx-data-view>

        <dmx-data-view id="qoc_view" dmx-bind:data="scEntries.data.entry.groupBy(`qocID`)" filter="($value[0].ageID == sel_agegroup.value.toNumber())"></dmx-data-view>

        <dmx-datetime id="var1"></dmx-datetime>

        <dmx-notifications id="notifies1"></dmx-notifications>

        <?php include 'admin_nav.php'; ?>

        <div class="container">

            <div class="row mt-1">

                <div class="col">

                    <h5 class="fw-bold d-print-none">EVENT STAGING</h5>

                </div>

            </div>

            <div class="row">

                <div class="col-8">

                    <div class="row">

                        <div class="col-5">

                            <select id="sel_agegroup" class="form-control d-print-block" dmx-bind:options="age_view.data" optiontext="$value[0].ageGroupID+' - '+$value[0].ageDescript" optionvalue="$value[0].ageID">

                            </select>

                        </div>

                        <div class="col">

                            <p dmx-text="qoc_view.items+' - '+sel_agegroup.value">&nbsp;</p>

                        </div>

                        <div class="col text-end">

                            <button id="btn1" class="btn btn-outline-primary d-print-none" onclick="window.print();return flase;"><i class="bi-printer-fill"></i></button>

                        </div>

                    </div>

                    <div class="row mt-2">

                        <div class="col-12">

                            <div class="table-responsive">

                                <table class="table table-striped table-sm">

                                    <thead>

                                        <tr class="small">

                                            <th>QOC#</th>

                                            <th>Division</th>

                                            <th>Name</th>

                                            <th>Rank</th>

                                            <th class="text-center">M/F</th>

                                            <th scope="row">Age</th>

                                            <th scope="row">K</th>

                                            <th scope="row">W</th>

                                            <th scope="row">S</th>

                                            <th scope="row">B</th>

                                            <th scope="row">G</th>

                                            <th scope="row" class="text-center"><i class="fas fa-user-check"></i></th>

                                        </tr>

                                    </thead>

                                    <tbody is="dmx-repeat" dmx-generator="bs5table" dmx-bind:repeat="qoc_view.data" id="tableRepeat1">

                                        <tr class="small">

                                            <td dmx-text="$value[0].qocID"></td>

                                            <td dmx-text="$value[0].divisionTitle"></td>

                                            <td dmx-text="$value[0].name_f+' '+$value[0].name_l"></td>

                                            <td dmx-text="$value[0].rank"></td>

                                            <td dmx-text="$value[0].gender" class="text-center"></td>

                                            <td dmx-text="$value[0].age"></td>

                                            <td dmx-text="$value[0].eventKata.toString().replace(1,'X').replace(0,'-')"></td>

                                            <td dmx-text="$value[0].eventWeapons.toString().replace(1,'X').replace(0,'-')"></td>

                                            <td dmx-text="$value[0].eventSparring.toString().replace(1,'X').replace(0,'-')"></td>

                                            <td dmx-text="$value[0].eventBlocker.toString().replace(1,'X').replace(0,'-')"></td>

                                            <td dmx-text="$value[0].eventGrappling.toString().replace(1,'X').replace(0,'-')"></td>

                                            <td class="text-center">

                                                <div dmx-show="$value[0].check_in == 1"><i class="text-success fas fa-user-check"></i></div>

                                                <div dmx-show="$value[0].check_in == 0"><i class="text-muted fas fa-user-alt-slash"></i></div>

                                            </td>

                                        </tr>

                                    </tbody>

                                </table>

                            </div>

                        </div>

                    </div>

                </div>

                <div class="col d-print-none">

                    <h5>Summary:</h5>

                    <div class="row">

                        <div class="col">

                            <div id="summaryInfo" is="dmx-repeat" dmx-bind:repeat="scEntries.data.entry.groupBy(`ageID`)">

                                <p class="small mb-0" dmx-text="$value.count().pad(3)+' | '+$value[0].ageGroupID+' - '+$value[0].ageDescript">&nbsp;</p>

                            </div>

                        </div>

                    </div>

                </div>

            </div>

        </div>

        <script src="../bootstrap/5/js/bootstrap.bundle.min.js"></script>

    </body>

    </html>


This is what the page looks like (NOTE: to get this image all code is removed from data-view filter)

This is the same page when I add the following code to the filter

($value[0].ageID == 1)

This should display 15 matching records

The Select is based on a data-view that is Grouped by ageID, so that only values with a match in the underlying data are displayed. As far as I know, $value[0].ageID is the only way to display values from a Group By array.

I may be wrong but when you group the value you are grouping by (e.g. ageID) becomes the key so you could possibly use

$key == 1

Did it work before with the same expression? When did it stop working, was this after updating the page?

Yes. It was functioning when I last used the page – but, that was nearly a year ago.

I had made no changes to the page.

I find it odd that any value placed in the filter causes the results to return empty.

I think it is related to a fix released in Wappler 4.8.2 where there were problems with the usage of the data-view within a repeater and they wanted to use the $index and $value from the repeater in the expression. Probably that fix broke your implementation.

Is it needed to use the groupBy, why not filter directly the array on the ageID and use the groupBy only on the repeater expression.

There are multiple records for each individual, hence the GroupBy, I only wanted a single row for each particular entry.

Looking at my tables, I believe I may have a simpler approach available.

Thanks for helping me unravel the WHY. It was making no sense to me why it was no longer functioning.