Records wont show in related feature table - Javascript API

1148
2
10-25-2017 01:35 PM
AaronThompson
New Contributor III

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

2 Replies
ValCannon2
New Contributor III

I am working from the same example and I cannot get it to work with my own feature layer. I downloaded the sample to my own server and it works great with the Esri feature service but not my own. I've tried it with a relate as well as a relationship class, published from ArcGIS Pro and ArcMap. Yes, my table is in the same database as the feature class and both are loaded in the map data frame when I publish. The only big difference from my results and yours is that when I click on the option to show related records, I get an empty content pane with no feature-table-grid in it. Not even headers. I think this has something to do with the way I am publishing my data but I can't figure out what. My service directory looks very similar to the Esri example. Did you ever resolve your issue?

0 Kudos
ValCannon2
New Contributor III

Update-

This has more to do with the field data type before you publish a service. You can get an empty related Feature Table if your Relationship Class key fields are LONG. Try converting them to STRING. It is odd that ArcMap and ArcGIS Pro both work fine with the fields as LONG, but when you publish a web service it converts them to INTEGER and seems to mess things up.  At least for related feature tables.

Esri support helped me find this and they may call it a bug, or maybe just a limitation.

0 Kudos