Select to view content in your preferred language

How can I access a relationship query through Attribute Inspector

2891
9
08-09-2010 09:20 AM
CharlesHarris
Emerging Contributor
I am extremely new to Flex and a relative novice to programming in general, but am making the migration from desktop to server.

I am trying to access a relationship query through the Attribute Inspector.  I have used the Attribute Inspector example from the samples website and have added the datagrid and relationship query definition to it.  I have done this so that I can compare the values between the Attribute inspector and the datagrid(relationship query is working in the datagrid).  However I'm not sure how to pass the fields returned from the relationship query to the Attribute Inspector.  When passing them to the datagrid I use "relatedDatagrid.dataProvider = fset.attributes;" in which fset is the featureset returned from my defined relationship query, however this does not work for the Attribute Inspector.  Any ideas?

I can post the entire code or snippets of code upon request.

Any help or advice would be appreciated

Jeremy
Tags (2)
0 Kudos
9 Replies
DasaPaddock
Esri Regular Contributor
The AttributeInspector only supports showing selected features from its associated FeatureLayers. You can create a FeatureLayer pointing to the url of the related table or layer and then call featureLayer.selectFeatures() on it.
0 Kudos
CharlesHarris
Emerging Contributor
Thanks Dasa-

I've gotten the Attribute Inspector to display the correct information however, I cannot edit it.  I'm guessing that this is because, the selection query is run on a feature layer of geometries and then the "key" is generated from the selected feature, once the "key" is generated it is used in a query on the table feature layer to select the related record in the table. 

How do I use attrInsp_updateFeatureHandler function to update the that record in the table?  In the attrInsp_updateFeatureHandler function, when it uses "event.feature.attributes.OBJECTID", what feature is this refering to, is it the feature layer feature originally selected by the click?

I've used "Alert.show(event.feature.attributes.OBJECTID)" to print this out to a window but it prints as "undefined".  If this were to return the proper OBJECTID, I could just change this to my "key" and run the same query as above to select the related record in the table and edit it, correct?

Sorry for the book, and thanks for any help...

Jeremy
0 Kudos
DasaPaddock
Esri Regular Contributor
I'm not sure what the "key" is that you're referring to?

This sample may be helpful:
http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=AttributeInspectorInfoWindowEditable

Notice how the attrInsp_updateFeatureHandler function is calling applyEdits() on the featurelayer.
0 Kudos
MLowry
by
Frequent Contributor
I'm not sure what the "key" is that you're referring to?

This sample may be helpful:
http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=AttributeInspectorInfoWindowEditable

Notice how the attrInsp_updateFeatureHandler function is calling applyEdits() on the featurelayer.


I think the 'key' is the attribute column which is used to relate both tables. The column which appears in both the table and the data being mapped.
0 Kudos
CharlesHarris
Emerging Contributor
I think the 'key' is the attribute column which is used to relate both tables. The column which appears in both the table and the data being mapped.


That is correct.  They key is the Primary/Foreign key that links the two tables together, in this case "Handle" in the polygon feature class and "ehandle" in the related table.

When I do the initial "click" query it selects the polygon feature class and in the "selectionCompleteHandler" I run another query to select the value of the key field from the selected feature and then use that value to find the related record in the related table.  I then display the attribute information of that record in the Attribute Inspector.  Easy enough...

My delima comes in here, inside of the "updateFeatureHandler".  I'm trying to understand what "feature" the "event.feature..." syntax is referring to, is it the polygon feature that was selected upon clicking the canvas or is it the record in the related table?  I've tried to print "event.featureLayer.LayerDetails" to the screen so I can see what fields are in the layer of the selected feature in order to determine which one the code is attempting to update but it keeps returning "undefined".

I hope that helps...
0 Kudos
DasaPaddock
Esri Regular Contributor
Try setting a breakpoint inside your "updateFeatureHandler" and then debug the app instead of trying to print the layerDetails. It's hard for me to tell without seeing the code, but the feature should be from the the layer that the FeatureLayer is pointing at.
0 Kudos
CharlesHarris
Emerging Contributor
Thanks for the help.  I have gotten this to work properly.  I needed to access "event.featureLayer.tableDetails" in the attrInsp_updateFeatureHandler function, which makes sense given that the feature is part of a feature layer that is a table in the database.
0 Kudos
MLowry
by
Frequent Contributor
Hi jeremy,


Would you mind posting the code you used to get the related results to work? I have spent quite a bit of time trying to figure this out with no luck yet.
0 Kudos
CharlesHarris
Emerging Contributor
Hi Mike-

Here is a word doc with the code that I implemented to get this to work.  I basically changed the sample Attribute Inspector code to include a new query in the "selectionCompleteHandler" so that once a feature has been selected by clicking on the canvas a query is performed to select the related record in my table(This is why I grab "ehandle" from my feature layer and make it equal it to "Handle" in the table, they are the key fields).  In the "updateFeatureHandler" I used "tableDetails" instead of "layerDetails" to get the field and attribute information from the table to display it in the Attribute Inspector.

Don't forget that you have to create a "Feature Layer" with your table as the endpoint and specify the fields for use in the Attribute Inspector.

Jeremy
0 Kudos