Select to view content in your preferred language

failed to show attribute window when add new feature by selecting from another layer

1329
10
10-25-2010 06:30 AM
XiujuZhou
Emerging Contributor
I have two polygon layers and create new feature for one layer by selecting polygon  from another layer. the selected polygon is highlighted without problem. I have a FeatureDataForm which is ESRI in house control as attribute data entry for the new feature, and need to show it right after the polygon is highlighted for user input for the new feature. the problem is that the FeatureDataForm apprears as blank popup window without attribute texbox. I need help of expertise here. the piece code is:
         
FeatureLayer myFeatureLayer = MyMap.Layers["dpcpoly"] as FeatureLayer; MyFeatureDataForm.FeatureLayer = myFeatureLayer;
MyFeatureDataForm.GraphicSource = copyGraphic; //copyGraphic is selected polygon from another layer.
FeatureDataFormBorder.Visibility = Visibility.Visible;
0 Kudos
10 Replies
JenniferNery
Esri Regular Contributor
Does your FeatureLayer have OutFields?  The FeatureDataForm determines what fields to show based on this.
0 Kudos
XiujuZhou
Emerging Contributor
yes the featureLayer  has OutFileds(*), and attribute window apprears without problem when create new feature by dwawing polygon using EditorWidet.

Does your FeatureLayer have OutFields?  The FeatureDataForm determines what fields to show based on this.
0 Kudos
AliMirzabeigi
Emerging Contributor
You need to check for the following in order to identify the problem:
- What is the type of your target layer (e.g. FeatureLayer,...)?
If the target layer is a FeatureLayer then:
- Does it have the same attribute (field) collection?
- Are you setting OutFields property of the target layer?

Also, how are you populating the "copyGraphic" in your source code? Is it a cloned graphic object or it still belongs to your first layer?
0 Kudos
XiujuZhou
Emerging Contributor
the target layer is FeatureLayer and OutFiels is set like the OutFields(*). the source is ArcGISDynamicMapServiceLayer. the two layers have totaly different attribute fields. So the attributes window is for the target layer. copyGraphic belongs to first layer and is created by code below:
private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args)
{
             Graphic feature = args.IdentifyResults[0].Feature;//IdentifyResults is from source layer
             copyGraphic = new Graphic()
            {
                        Symbol = searchFillSymbol,
                        Geometry = feature.Geometry
            };
            hilightGraphicsLayer.Graphics.Add(copyGraphic);
            FeatureLayer myFeatureLayer = MyMap.Layers["dpcpoly"] as FeatureLayer;//dpcpoly is the target layer
            MyFeatureDataForm.FeatureLayer = myFeatureLayer;
            MyFeatureDataForm.GraphicSource = copyGraphic;
            FeatureDataFormBorder.Visibility = Visibility.Visible;
}

You need to check for the following in order to identify the problem:
- What is the type of your target layer (e.g. FeatureLayer,...)?
If the target layer is a FeatureLayer then:
- Does it have the same attribute (field) collection?
- Are you setting OutFields property of the target layer?

Also, how are you populating the "copyGraphic" in your source code? Is it a cloned graphic object or it still belongs to your first layer?
0 Kudos
AliMirzabeigi
Emerging Contributor
From what I see in your code the "copyGraphic" doesn't have any attributes defined (just the Geometry and the Symbol). You need to use Attributes.Add() method of the Graphic object to define and populate corresponding attributes and their values.
0 Kudos
XiujuZhou
Emerging Contributor
copyGraphic is from source and dosn't need attribute window from source. since FeatureLayer of FeatureDataForm is set like this: MyFeatureDataForm.FeatureLayer = myFeatureLayer. I thought FeatureDataForm is going to have attribute fields shows for myFeatureLayer which is target layer. It is correct? if not, I need Attributes.Add() for graphic like you suggest. I add attributes like below:
FeatureLayer myFeatureLayer = MyMap.Layers["dpcpoly"] as FeatureLayer;
           // copyGraphic.Attributes.Add(myFeatureLayer.OutFields[0].ToString(),3111);
            copyGraphic.Attributes.Add("DPC_ID", null);
            copyGraphic.Attributes.Add("SUBDIVISION", null);
            copyGraphic.Attributes.Add("KEYMAP", null);
            MyFeatureDataForm.FeatureLayer = myFeatureLayer;
            MyFeatureDataForm.GraphicSource = copyGraphic;
            FeatureDataFormBorder.Visibility = Visibility.Visible;
however there is still no field appears in the attribute form.
Also how to make the attribute window show like the attribute form defined in the FeatureLayer of target, such as dropdown box of subtype field, calendar from date type field, data validations etc.?

From what I see in your code the "copyGraphic" doesn't have any attributes defined (just the Geometry and the Symbol). You need to use Attributes.Add() method of the Graphic object to define and populate corresponding attributes and their values.
0 Kudos
AliMirzabeigi
Emerging Contributor
Does "myFeatureLayer" in your code have "DPC_ID", "SUBDIVISION", and "KEYMAP" attributes? The reason I'm asking is that FeatureDataForm gets attribute definitions from its associated "FeatureLayer" property and if "myFeatureLayer" doesn't have the above properties in it nothing will show up regardless of your attribute definitions in your "copyGraphic".
0 Kudos
XiujuZhou
Emerging Contributor
Yes "myFeatureLayer" has the attributes. But I do not want save attribute by code. I still need attribute window for user's input and need the window to be exactly like the attribute form defined in Feature Service such data validation, calender for date, dropdown box for subtype etc. in another word, I still want to use the attribute window like the one in EditorWiget.

Does "myFeatureLayer" in your code have "DPC_ID", "SUBDIVISION", and "KEYMAP" attributes? The reason I'm asking is that FeatureDataForm gets attribute definitions from its associated "FeatureLayer" property and if "myFeatureLayer" doesn't have the above properties in it nothing will show up regardless of your attribute definitions in your "copyGraphic".
0 Kudos
JenniferNery
Esri Regular Contributor
Before adding the graphic to your target layer. You do need to add attributes to your graphic as Ali suggested.
FeatureLayer target = this.MyMap.Layers["TargetLayer"] as FeatureLayer;
Graphic graphic = new Graphic() { Geometry =  feature.Geometry };  
foreach (var field in target.LayerInfo.Fields)
 graphic.Attributes.Add(field.Name, null);
target.Graphics.Add(graphic);


I was using this as my target layer:
http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer...
Notice, that the FeatureDataForm uses the proper control depending on the field type and the same validation check applies.
0 Kudos