Select to view content in your preferred language

Bind FeatureDataGrid to SubLayer

1260
8
04-08-2011 09:25 AM
EricPfirman
Occasional Contributor
Is it possible to bind a FeatureDataGrid to a "sub-layer" like this?
<esri:FeatureDataGrid Grid.Column="3"
x:Name="MyDataGrid"
Map="{Binding ElementName=Map}"
GraphicsLayer="{Binding ElementName=Map, Path=Layers.[WalisLayer].Layers.[1]}" >
</esri:FeatureDataGrid>

where WalisLayer is this:
<esri:ArcGISDynamicMapServiceLayer
ID="WalisLayer"
Initialized="ArcGISDynamicMapServiceLayer_Initialized"/>
0 Kudos
8 Replies
JenniferNery
Esri Regular Contributor
No this is not supported.

FeatureDataGrid.GraphicsLayer must be of type GraphicsLayer. FeatureLayer for example inherits from GraphicsLayer. You can either perform a query on this sub layer URL and put the results in a GraphicsLayer or create a FeatureLayer with this sub layer URL, then use this layer to set FeatureDataGrid.GraphicsLayer property.
0 Kudos
EricElder
Occasional Contributor
No this is not supported.

FeatureDataGrid.GraphicsLayer must be of type GraphicsLayer. FeatureLayer for example inherits from GraphicsLayer. You can either perform a query on this sub layer URL and put the results in a GraphicsLayer or create a FeatureLayer with this sub layer URL, then use this layer to set FeatureDataGrid.GraphicsLayer property.


I am struggling to get the "zoom to selection" and "auto zoom to selected" to work after performing a query on the sub layer URL and putting the results in a GraphicsLayer.


Eric
0 Kudos
JenniferNery
Esri Regular Contributor
I could not reproduce the issue. I am still able to Auto Zoom to Selection. In your Query, did you set OutSpatialReference to be your Map.SpatialReference?

Also it might be easier to set up and robust to FeatureDataGrid if you've used FeatureLayer since FDG will base its columns on Fields information, metadata that is available on FeatureLayer.
0 Kudos
EricElder
Occasional Contributor
Most of my logic is in C#.  I suspect my issue is the relationship of the featurelayer and graphics layer.  Here is some of my code:

The Query:

                   for (int i = 0; i < theSubLayers.Count(); i++)
                    {
                        theLayInfo = (LayerInfo)theSubLayers.GetValue(i);
                        if (theLayInfo.Name == theActiveLayerName)
                        {

                            //Do a query to return all the records for the featuredatagrid
                            QueryTask theQueryTask = new QueryTask();
                            theQueryTask.ExecuteCompleted += Query_ExecuteCompleted;
                            Query theQuery = new Query();
                            theQuery.ReturnGeometry = true;
                            theQuery.Where = "1=1";
                            theQuery.OutSpatialReference = MyMap.SpatialReference;
                            theQuery.OutFields.Add("*");
                            theQueryTask.Url = dynamicLayer.Url + "/" + i.ToString();
                            theQueryTask.ExecuteAsync(theQuery, "initial");

                            break;
                        }
                    }




The Query_ExecuteCompleted:

            FeatureLayer theFeatureLayer = new FeatureLayer();

            FeatureSet theFeatSet = args.FeatureSet;
            if (theFeatSet != null && theFeatSet.Features.Count > 0)
            {
                GraphicsLayer theGraphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

                theGraphicsLayer.Graphics.Clear();
                foreach (Graphic theGFeature in theFeatSet.Features)
                {
                    theGraphicsLayer.Graphics.Insert(0, theGFeature);
                }
                featureDataGrid1.GraphicsLayer = theGraphicsLayer;

                //Set renderer to the graphics layer
                IRenderer theRenderer;
                theRenderer = grid1.Resources["SelectRenderer"] as ESRI.ArcGIS.Client.IRenderer;
                theGraphicsLayer.Renderer = theRenderer;
            }
0 Kudos
JenniferNery
Esri Regular Contributor
Your code looks fine but I think FDG will take longer to load if you use GraphicsLayer, it might be better to use FeatureLayer, which would also cut down your code to:

var layer = new FeatureLayer() 
{
Url = string.Format("{0}/{1}", dynamicLayer.Url, i),
};
MyMap.Layers.Add(layer);
featureDataGrid1.GraphicsLayer = layer;
0 Kudos
EricElder
Occasional Contributor
I'm currently struggling with the query returning the attributes okay, but graphics are always null.  I tried the featurelayer code with no success.

Does the service have to have Feature Access selected?  Currently the service has just Mapping.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I'm currently struggling with the query returning the attributes okay, but graphics are always null. I tried the featurelayer code with no success.

Does the service have to have Feature Access selected? Currently the service has just Mapping.


Feature Acces is not needed for displaying graphics.

It might be a renderer issue. Check that your renderer is defining symbols matching the geometry type of your graphics (e.g. MarkerSymbol for Point, LineSymbol for Polyline,....).
Else try using fiddler to look at the request sent to the server, that might give a clue.
0 Kudos
EricElder
Occasional Contributor
Well...I can't believe it.  It looks like the main issue I have been having was I had the feature layers Shape fields turned off when I created the Map Services.
0 Kudos