Select to view content in your preferred language

SubTypes and Field Alias names

1667
3
10-25-2011 08:23 AM
ChristineZeller
Occasional Contributor
Sorry if the answer is already out there in another post, I did a search and couldn't find anything.  

I have a featurelayer that I can query and view attributes within Feature Data Grid; the problem is when I view this information in the Table Grid the subtypes display the values (0, 1, 2, 3, ect.) and not the labels (Hospital, Fire House, PD, etc.).  Also the field names are displayed instead of the field alias names (this isn't as big as a deal as the subtypes).

If I use the identify tool (from the sdk) everything is displayed great (subtype labels instead of values and alias instead of actually field names). 

Also I have the editing tools from the sdk up and running for this feature layer and I'm experiencing the same problem with the subtypes values.  The domains are awesome...provides the drop down list but the subtype field doesn't give a drop downlist and defaults to the value (0) instead of the label (Hosipital). 

Can someone point me to a post or help me out with getting started to solve this issue.

Thanks
Christine.
0 Kudos
3 Replies
ChristineZeller
Occasional Contributor
I did some more searching and came across this suggestion by Jennifer...see this post #8

http://forums.arcgis.com/threads/23731-Problem-with-Date-attribute-field

Jennfier and Ali pointed out
use FeatureLayer to assign to FeatureDataGrid.GraphicsLayer property if you want to preserve field information, instead of performing a QueryTask and then putting results to a GraphicsLayer. You can still perform queries using FeatureLayer by updating Where clause.


So i'm having a little trouble taking Jennifer's suggestion, digesting it, and implementing it.  I'm hoping someone can point me a direction with some sample code.  Below I'll post my spatial query code.

XAML declare my feature layer
 <esri:FeatureLayer ID="MAINPOINTS" DisableClientCaching="True" 
                               AutoSave="False"
                               Url="http://myserver/ArcGIS/rest/services/gdb/FeatureServer/0" 
                               OutFields="*" Mode="OnDemand">



Here's my xaml for my featureTableGrid


 <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="15" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <TextBlock x:Name="DataDisplayTitle" Text="Search Results" FontSize="9" Grid.Row="0" FontWeight="Bold" FontFamily="Arial" Foreground="#FFFFFFFF" />



                            <esriWidgets:FeatureDataGrid Grid.Row="1" x:Name="QueryDetailsDataGrid" Height="170" 
                                      Map="{Binding ElementName=Map}" 
                                      GraphicsLayer="{Binding Layers[MySelectionGraphicsLayer], ElementName=Map}" Style="{StaticResource FeatureDataGridStyle1}"  />

                        </Grid>




Here's my code behind to set my active layer, which works with my Attribute and Spatial Select


string baseUrl = "http://myserver/ArcGIS/rest/services/gdb/MapServer";
       
            for (int i = 0; i <= 1; i++)
            {
                FeatureLayer featureLayer = new FeatureLayer() { Url = string.Format("{0}/{1}", baseUrl, i) };
                featureLayer.Initialize();
                layers.Add(featureLayer);
            }

            //layers.RemoveAt(1);
            Layers.ItemsSource = layers;
            Layers.SelectedIndex = 0;



Here's my Code Behind for my Spatial Selection


 #region Spatial Query

        private void esriTools_ToolbarItemClicked(object sender, ESRI.ArcGIS.Client.Toolkit.SelectedToolbarItemArgs e)
        {
            switch (e.Index)
            {
                case 0: // Point
                    MyDrawSurface.DrawMode = DrawMode.Point;
                    break;
                case 1: // Polyline
                    MyDrawSurface.DrawMode = DrawMode.Polyline;
                    break;
                case 2: // Polygon
                    MyDrawSurface.DrawMode = DrawMode.Polygon;
                    break;
                case 3: // Rectangle
                    MyDrawSurface.DrawMode = DrawMode.Rectangle;
                    break;
                default: // Clear
                    MyDrawSurface.DrawMode = DrawMode.None;
                    GraphicsLayer selectionGraphicslayer = Map.Layers["MySelectionGraphicsLayer"] as GraphicsLayer;
                    selectionGraphicslayer.ClearGraphics();
                    QueryDetailsDataGrid.ItemsSource = null;
                    ResultsDisplay.IsExpanded = false;
                    break;
            }
            MyDrawSurface.IsEnabled = (MyDrawSurface.DrawMode != DrawMode.None);
            StatusTextBlock.Text = e.Item.Text;
        }

        private void MyDrawSurface_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args)
        {


            GraphicsLayer selectionGraphicslayer = Map.Layers["MySelectionGraphicsLayer"] as GraphicsLayer;
            selectionGraphicslayer.ClearGraphics();


            QueryTask queryTask = new QueryTask((Layers.SelectedItem as FeatureLayer).Url);
 
            queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
            queryTask.Failed += QueryTask_Failed;

            Query query = new ESRI.ArcGIS.Client.Tasks.Query();

            query.OutFields.Add("*");

            query.Geometry = args.Geometry;

            // Return geometry with result features
            query.ReturnGeometry = true;

            queryTask.ExecuteAsync(query);



        }

        private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)
        {
            FeatureSet featureSet = args.FeatureSet;

            if (featureSet == null || featureSet.Features.Count < 1)
            {
                MessageBox.Show("No features retured from query");
                return;
            }

            GraphicsLayer graphicsLayer = Map.Layers["MySelectionGraphicsLayer"] as GraphicsLayer;


            if (featureSet != null && featureSet.Features.Count > 0)

               // ResultsDisplay.Visibility = Visibility.Visible;

            {
                foreach (Graphic feature in featureSet.Features)
                {

                    switch (featureSet.GeometryType.ToString())
                    {
                        case "Polygon":
                            feature.Symbol = LayoutRoot.Resources["ResultsFillSymbol"] as FillSymbol;
                            break;
                        case "Polyline":
                            feature.Symbol = LayoutRoot.Resources["CustomGrowLineSymbol"] as LineSymbol;
                            break;
                        case "Point":
                            feature.Symbol = LayoutRoot.Resources["ResultsMarkerSymbol"] as SimpleMarkerSymbol;
                            break;
                    }

                    graphicsLayer.Graphics.Insert(0, feature);
                    
                }
                
                ResultsDisplay.IsExpanded = true;
            }
            MyDrawSurface.IsEnabled = false;
        }

        private void QueryTask_Failed(object sender, TaskFailedEventArgs args)
        {
            MessageBox.Show("Query failed: " + args.Error);
        }


        #endregion




Thanks for taking a look.

Christine
0 Kudos
ChristineZeller
Occasional Contributor
Step away for awhile...trying to get back into this and still wondering if anyone can jump start me.
0 Kudos
PreetiMaske
Esri Regular Contributor
If you are using v2.2 , then FeatureDataGrid in v.2.2 will display labels for codedvaluedomains but does not display labels for subtypes.  It will only display the number for subtypes. But in upcoming release you will find dropdowns in FeatureDatagrid for types and Subtypes fields, displaying the labels.

ArcGIS API for Silverlight 3.0 beta 1 already includeds this functionality, if you want to give it a try.
0 Kudos