AnsweredAssumed Answered

Records wont show in related feature table - Javascript API

Question asked by athompson_otp on Oct 25, 2017

Hello all!

 

I am trying to make a webapp that simply has a table (no map) of records drawn from a feature service, and can show related records as well. I found this handy example in the documentation. I can get it to display my feature service records correctly, but I am unable to get the related records to show. After clicking on the option to show related records, a table appears with the correct schema, but that is all. No rows show. I posted the code below but took out the feature service URLs. Anybody see anything blatantly obvious that won't allow me to see my related records?

 

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>OTP Facility Equipment</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.22/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.22/esri/css/esri.css">
<script src="https://js.arcgis.com/3.22/"></script>
<style>
html,
body,
#myTableNode
{
width:100%;
height:100%;
margin:0;
padding:0;
}
#top,
#bot
{
margin: 0;
padding: 0;
}
</style>

<script>
var equipment;
function chooseEquipmentType(choice){
equipment = choice;
console.log("Equipment Variable is now: " + equipment)
console.log('Service URL is : ' + " MY FEATURE SERVICE URL")
//Allows the page to dynamically change when a new button is clicked
dijit.registry.remove('myTableNode')
var map;
require([
"esri/layers/FeatureLayer",
"esri/dijit/FeatureTable",
"dojo/dom",
"dojo/parser",
"dojo/ready",
], function (
FeatureLayer, FeatureTable,
dom, parser, ready
) {
parser.parse();
ready(function(){
// Create the feature layer
var myFeatureLayer = new FeatureLayer("MY FEATURE SERVICE URL", {
mode: FeatureLayer.MODE_ONDEMAND,
outFields: ["*"],
visible: true,
id: "fLayer"
});
myTable = new FeatureTable({
featureLayer : myFeatureLayer,
showGridMenu: true,
showAttachments: true,
showRelatedRecords: true,
hiddenFields: ['Facility_ID', 'In_Service','GlobalID', 'Parent_GUID', 'Line_Name', 'Line_Name2', 'Line_Group', 'Line_kV', 'OBJECTID', 'GUID_Calculate', 'created_user', 'created_date', 'last_edited_user', 'last_edited_date'] // field that end-user can show, but is hidden on startup
}, "myTableNode");
myTable.startup();

// listen to row-click event
// to hide visible popups
myFeatureTable.on("row-select", function(evt){
if (map.infoWindow.isShowing){
map.infoWindow.hide();
}
});
// listen to show-attachments event
myFeatureTable.on("show-attachments", function(evt){
console.log("show-attachments event - ", evt);
});
// listen to show-related-records event
myFeatureTable.on("show-related-records", function(evt){
console.log("show-related-records event - ", evt);
});
});
});
}
</script>

<body class="claro esri">
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline', gutters: false" style="width:100%; height:100%;">
<div id="top" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">
<p>Click on a type of equipment in the dropdown to see all records currently inventoried in GIS.</p>
<p >
<select name="equipmentType" onchange="chooseEquipmentType(this.value)">
<option value="">Please select an equipment type</option>
<option value="Battery_Bank">Battery Bank</option>
<option value="Breaker">Breaker</option>
<option value="Capacitor_Bank">Capacitor Bank</option>
<option value="Circuit_Switcher">Circuit Switcher</option>
<option value="Motor_Operator">Motor Operator</option>
<option value="Recloser">Recloser</option>
<option value="Regulator">Regulator</option>
<option value="Facility_Transformer">Facility Transformer</option>
</select>
<br>
<br>
</p>
</div>
<div id="bot" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'">
<div id="myTableNode"></div>
</div>
</div>
</body>
</html>

 

 

Any help would be greatly appreciated. 

 

Thanks

Aaron

Outcomes