Add Attributes
Afternoon,
I have a QueryTask that returns a FeatureSet. The FeatureSet contains list of graphics with attributes.
Using a ForEach<Graphic> on FeatureSet.Features I can iterate through each graphic, I can even change the text of the attributes using Assign, item.Attributes.Item("NAME") = CType("I EDITED YOU",String).
This seems very simple, but how about adding a new attribute?
Am I correct in thinking the list of graphics is an IDictionary? Could I use an Invoke Method somehow? Maybe TargetType = null, TargetObject = item.Attributes and MethodName = Add? I've tried a number of methods and i can't get a new attribute to appear? This is only for display purposes.
Thanks
-
Update on this.
I have the Invoke Method setup as described. There are two Parameters, In String "NAME" and In Object "New Name".
If i then loop through the graphics within my featureset item.Attributes("NAME") shows me "New Name".
Yet when I use the SelectFeatures tool the new attribute isn't showing.
Any ideas?
Thanks
0 -
Hi
Figured this out for myseld in the end. I had to add a new Field to the featureset to get the new attribute to show.
0 -
how did you add a new field to a featureset. i would like to know how to do that. can you provide a sample syntax or a workflow snippet?
0 -
Create a new variable of type ESRI.ArcGIS.Client.Field and Default value e.g. New ESRI.ArcGIS.Client.Field("FIELD_NAME", ESRI.ArcGIS.Client.Field.FieldType.String, "FIELD_NAME", Nothing, False, True, 100). Then use the InvokeMethod tool. TargetType null, TargetObject being your FeatureSet and MethodName Add. In the parameters Direction In, Type Field, Value being the varible you created above.
0 -
Trying to add an attribute to a featureset with little success. Anyone kind enough to share an example?
0 -
Also, I'm having trouble getting the "methodname" in the invoke methode activity to understand "Add". It's saying that "Add" is not a public method on Featureset. 0 -
Have tried this and the TargetObject needs to be _featuresetvariable.Fields at which point the Add is recognised. Thanks Matthew for the details, saved me a lot of hassle. 0 -
I can see the new temp field I have added (using above instructions - thank you!) ONLY if I iterate through the field collection in my workflow. When the selected recs come up in the viewer the new field is not showing up.
However, I need the new field and the attributes I set to be visible when I do the SelectFeatures tool, as I need to be able to label features based on this 'new' temporary field. Any thoughts on why this isn't showing up?0 -
Figured it out... in the Select Features tool, I needed to leave the Map Service ID blank so it would use the featureset to select and use those fields, not the configured fields in the map service. Also helpful to know is that once I did this, things that I had set as invisible like OBJECTID and GLOBALID show up again in the table. So, you will have to remove those from the featureset if you don't want to see them. 0 -
Ok, one more question, as I am still scratching my head...
I have my featureset showing up in the results table, with my new field as the last field in the table. I need my new field to be the FIRST column in the table, so that users can see the values without having to scroll to the end.
To add this field, I am using the InvokeMethod to add a field to the featureset. Works great, but is there a way to specify an index for adding the new field to the featureset? I'd like to add it at index 0 so it would be the first column and not the last.
Any ideas?0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
10 Kommentare