Select to view content in your preferred language

view.hitTest gives origianal results after editing/updating data

55
0
yesterday
Mr_Kirkwood
Regular Contributor

I have a query that grabs the ID for a building. If the building layer is the only layer on i get the ID from that. If the Rooms layer is on I get the ID from that layer. I use the ID to run a query to get people assigned to the room. When I add/remove a person the view.hitTest gives me the original hit test query. All of the data tables update and the popup reflects the updated data. But when i identify after making the edits the view.hitTest has not changed in atrributes. Here is my code:

view.on("click", function (event) {
    // Handle feature selection here
    console.log("Get Selected Features Data")
    // Array of layers to exclude
    const options = {
        exclude: [floorOutline]
    };

    view.hitTest(event, options).then(function (response) {
        for (var i = 0; i < response.results.length; i++) {
            result = response.results[i];
            graphic = result.graphic;
            attributes = graphic.attributes;
            mySpaceID = attributes.SPACEID;
            layer = result.layer;


            console.log("BuildingID from Buildings");
            console.log(attributes.BUILDINGID);
            buildingIDQuery = attributes.BUILDINGID;

            console.log("BuildingID from Rooms");
            console.log(attributes.BUILDINGKEY);

            if (attributes.BUILDINGKEY == undefined) {
                buildingNameOutput = attributes.LONGNAME;
                buildingZoom = attributes.OBJECTID
                console.log(attributes.OBJECTID);

            } else {
                getSpaceObjectID();
            }


            return result.graphic.layer === layer
        }

    });
});
function getSpaceObjectID ()
{
    console.log ("employeeAssignmentData")
    getObjectIDText = mySpaceID;
    console.log (getObjectIDText);
    if (getObjectIDText === null) {
        console.log ("no employee")
    } else {
        roomsAssignedData = [];
        $ ('#assignedEmployeesTable').jqxGrid ('clear')
        employeeAssignmentData.filter (c => c.SPACEKEY === mySpaceID).forEach (function (d)
        {
            console.log ("Get Employee Info");
            console.log ("SPACEKEY")
            console.log (d.SPACEKEY);
            console.log ("EMPLOYEEKEY")
            console.log (d.EMPLOYEEKEY);
            myObjectID = d.OBJECTID;
            myEmployeeKey = d.EMPLOYEEKEY
            mySpaceID = d.SPACEKEY
            initAssignedEmployeesQuery (mySpaceID);
            roomsAssignedData.push (
                    myEmployeeKey
                    );
            console.log (roomsAssignedData);
            $ ("#jqxNavigationBar").jqxNavigationBar ({expandedIndexes: [4]});

        });
    }
}

The atatched show the hitTest after i added a fourth employee but the console log still shows only 3. How do i clear the query so that it refreshed the hitTest? 

0 Kudos
0 Replies