Selection in FeatureDataGrid

497
4
03-28-2014 04:08 AM
UlfGrimhardt
New Contributor
Hello,

i have a question concerning the selection of a FeatureDataGrids or FeatureLayers.
In my Application i have a FeatureLayer and a FeatureDataGrid. If i select a row in the datagrid the feature in the map is selected and vise versa. Now i would like to select a Feature via CodeBehind. Is that possible?

For example i would like to select the feature by specific Attributes.

Thanks in Advance!
0 Kudos
4 Replies
AhmedEl-Sisi
Occasional Contributor III
Hello,

i have a question concerning the selection of a FeatureDataGrids or FeatureLayers.
In my Application i have a FeatureLayer and a FeatureDataGrid. If i select a row in the datagrid the feature in the map is selected and vise versa. Now i would like to select a Feature via CodeBehind. Is that possible?

For example i would like to select the feature by specific Attributes.

Thanks in Advance!


Hi,
you can select a feature via code behind using Graphic.Select() method or Graphic.Selected property.

for example, you can select some existing features from a FeatureLayer using somthing like the following:
 
List<Graphic> filteredGraphics = featureLayer.Graphics.Where(g => Convert.ToString(g.Attributes["AttributeKey"]) == "AttributeValue").ToList();
 foreach (Graphic g in filteredGraphics)
 {
    g.Select();
 }
0 Kudos
UlfGrimhardt
New Contributor
Ok thank you for the help.
That works great if i set the FeatureLayer Mode to "OnDemand" or "Snapshot", but if i set it so SelectionOnly no Feature is shown.
The filteredGraphics List in your Code doesnt contains any Features so no Feautre is found.

It would be great if i could select a feature by code from the layer and just the features that fulfill the where-clause are shown in the DataGrid.

Do you have any Ideas concerning that problem?

Thanks in Advance

Ulf
0 Kudos
AhmedEl-Sisi
Occasional Contributor III
Ok thank you for the help.
That works great if i set the FeatureLayer Mode to "OnDemand" or "Snapshot", but if i set it so SelectionOnly no Feature is shown.
The filteredGraphics List in your Code doesnt contains any Features so no Feautre is found.

It would be great if i could select a feature by code from the layer and just the features that fulfill the where-clause are shown in the DataGrid.

Do you have any Ideas concerning that problem?

Thanks in Advance

Ulf


Use FeatureLayer.WhereClause to filter your features and remove SelectionOnly Mode.
0 Kudos
UlfGrimhardt
New Contributor
Thanks for the Info! That helped to solve my Problem!
0 Kudos