Attribute Inspector Relationship Query

1137
9
09-29-2010 06:52 AM
KellyBoyd
New Contributor III
Hello,
Does the attribute inspector support editing with relationship queries?  If so, would it just be a matter of changing the selectQuery to a RelationshipQuery in the sample?
Thanks,
Kelly
0 Kudos
9 Replies
TimothyMichael
Occasional Contributor II
Did you ever get an answer?  I have been thinking about the same thing...essentially, I have been modifying the Public Works/Citizen Request template for ArcGIS 10 and I would like to collect the attributes to a related table instead of to the feature service.  The samples that I have found for editing related records have them being edited after a point has already been created, while I need to have it happen at the same time.

Thanks,
Tim
0 Kudos
SuzanneEctor
New Contributor
I need to know this, too.... Anyone?
0 Kudos
SuzanneEctor
New Contributor
I think web editing on related tables is not supported for M-M, but works for 1-M.
0 Kudos
TimothyMichael
Occasional Contributor II
We ultimately ended up going a different direction, eliminating the need for a relationship class.  I did work with an ESRI analyst and they were able to send me code to directly edit a table through javascript.  We never implemented it, but I can post it here if you think it will help.
0 Kudos
SuzanneEctor
New Contributor
We ultimately ended up going a different direction, eliminating the need for a relationship class.  I did work with an ESRI analyst and they were able to send me code to directly edit a table through javascript.  We never implemented it, but I can post it here if you think it will help.


Yes, that would be great!  Thanks.
0 Kudos
TimothyMichael
Occasional Contributor II
Sorry for the delay, here you go...
______


Here is a complete working set of code that edits an Esri stand alone table.  To get it working at your site find the line about line 22 where there is a reference to a proxy page.  Make a proxy page on your server and change the reference to point to your server's proxy page.

esri.config.defaults.io.proxyUrl = "http://MyServer/proxy/proxy.ashx";


-------------html below

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   <meta http-equiv="X-UA-Compatible" content="IE=7" />
   <!--The viewport meta tag is used to improve the presentation and behavior of the samples
     on iOS devices-->
   <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
   <title>Editable FeatureLayer with Attribute Inspector</title>
      <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css">
   <script type="text/javascript">
     var djConfig = {parseOnLoad: true};
   </script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script>
<script type="text/javascript" language="Javascript">
     dojo.require("esri.dijit.AttributeInspector-all");
     var attInspector;
     function init() {
       //This sample requires a proxy page to handle communications with the ArcGIS Server services. You will need to
       //replace the url below with the location of a proxy on your machine. See the 'Using the proxy page' help topic
       //for details on setting up a proxy page.
       esri.config.defaults.io.proxyUrl = "http://MyServer/proxy/proxy.ashx";
       var table = new esri.layers.FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/1", {
         outFields: ["*"],
         mode:esri.layers.FeatureLayer.MODE_SELECTION
       });
       dojo.connect(table, "onLoad", initAttributeInspector);
     }
     function initAttributeInspector(table) {
       attInspector = new esri.dijit.AttributeInspector({layerInfos:[{'featureLayer':table}]}, "attrInspector");
       dojo.connect(attInspector, "onDelete",function(feature){
         table.applyEdits(null,null,[feature]);
       });
       dojo.connect(attInspector, "onAttributeChange", function(feature,fieldName,newFieldValue) {
         feature.attributes[fieldName] = newFieldValue;
         table.applyEdits(null, [feature], null);
       });
       var query = new esri.tasks.Query();
       query.where = "agree_with_incident  = 1";
       table.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW, function(features) {
         console.log(features);
         attInspector.refresh();
       });
     }
     dojo.addOnLoad(init);
   </script>
</head>
<body class="claro">
   <div>Modify attributes for records in the Incident Priority table. </div>
   <div id="attrInspector" style="width:300px; height:400px; border:1px solid #000;"></div>
</body>
</html>


-------------html above



Regards,
0 Kudos
MarcoWagemakers
Occasional Contributor
Hello,

Thanks for the code. Below some code to add a new record to the related table. Is this the right way to do that?

             //open data of new record in attInspector
dojo.connect(table, 'onEditsComplete', function(addResults, updateResults, deleteResults){
  if (addResults[0] != null) {
   console.log(addResults[0].objectId + " new record objectid");
   var query = new esri.tasks.Query();
   query.where = "ObjectID =" + addResults[0].objectId;
   table.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW, function(features){
    console.log(features);
    attInspector.refresh();
   });
  }
});

             //add new record to the table by related field Puntnummer
var melding = {
  attributes: {
   Puntnummer: '176-04',
   TijdstipMelding: new Date().getTime()
  }
};
table.applyEdits([melding], null, null);

Marco
0 Kudos
TimothyMichael
Occasional Contributor II
Not sure.  I think the code that I posted from the analyst was to edit a table directly, not a related record.
0 Kudos
JHayes
by
Occasional Contributor
We ultimately ended up going a different direction, eliminating the need for a relationship class.  I did work with an ESRI analyst and they were able to send me code to directly edit a table through javascript.  We never implemented it, but I can post it here if you think it will help.



What did you do?  I'm trying to piece together an app that renders and queries data in a table that's linked to the feature via a relationship class.  Have you seen this before? 

Joe
0 Kudos