var fieldsToDisplay = new List<string>() {"fieldName1", fieldName2"}; var attributesToDisplay = new Dictionary<string, object>(); foreach(var item in selectedFeature.Attributes) if(fieldsToDisplay.Contains(item.Key)) attributesToDisplay[item.Key]= item.Value; IdentifyDetailsDataGrid.ItemsSource = attributesToDisplay;
public void ShowFeatures(List<IdentifyResult> results) { _dataItems = new List<DataItem>(); if (results != null && results.Count > 0) { foreach (IdentifyResult result in results) { Graphic feature = result.Feature; string title = result.Value.ToString() + " (" + result.LayerName + ")"; _dataItems.Add(new DataItem() { Title = title, Data = feature.Attributes }); var fieldsToDisplay = new List<string>() { "School Name", "Address", "Zip", "Phone", "Website", "School District" }; var attributesToDisplay = new Dictionary<string, object>(); foreach (var item in feature.Attributes) if (fieldsToDisplay.Contains(item.Key)) attributesToDisplay[item.Key] = item.Value; if (result.LayerId == 4) IdentifyDetailsDataGrid.ItemsSource = attributesToDisplay; if (result.LayerId == 9) IdentifyDetailsDataGrid2.ItemsSource = attributesToDisplay; if (result.LayerId == 14) IdentifyDetailsDataGrid3.ItemsSource = attributesToDisplay; } //IdentifyComboBox.SelectedIndex = 0; }
Never mind, I got it with the following code: public void ShowFeatures(List<IdentifyResult> results) { _dataItems = new List<DataItem>(); if (results != null && results.Count > 0) { foreach (IdentifyResult result in results) { Graphic feature = result.Feature; string title = result.Value.ToString() + " (" + result.LayerName + ")"; _dataItems.Add(new DataItem() { Title = title, Data = feature.Attributes }); var fieldsToDisplay = new List<string>() { "School Name", "Address", "Zip", "Phone", "Website", "School District" }; var attributesToDisplay = new Dictionary<string, object>(); foreach (var item in feature.Attributes) if (fieldsToDisplay.Contains(item.Key)) attributesToDisplay[item.Key] = item.Value; if (result.LayerId == 4) IdentifyDetailsDataGrid.ItemsSource = feature.Attributes; IdentifyDetailsDataGrid.ItemsSource = attributesToDisplay; if (result.LayerId == 9) IdentifyDetailsDataGrid2.ItemsSource = feature.Attributes; IdentifyDetailsDataGrid2.ItemsSource = attributesToDisplay; if (result.LayerId == 14) IdentifyDetailsDataGrid3.ItemsSource = feature.Attributes; IdentifyDetailsDataGrid3.ItemsSource = attributesToDisplay; }Now all I need it to set the field attribute of "Website" to be a hyperlink in all three data grids.
public void ShowFeatures(List<IdentifyResult> results) { _dataItems = new List<DataItem>(); if (results != null && results.Count > 0) { foreach (IdentifyResult result in results) { Graphic feature = result.Feature; string title = result.Value.ToString() + " (" + result.LayerName + ")"; _dataItems.Add(new DataItem() { Title = title, Data = feature.Attributes }); var fieldsToDisplay = new List<string>() { "School Name", "Address", "Zip", "Phone", "Website", "School District" }; var attributesToDisplay = new Dictionary<string, object>(); foreach (var item in feature.Attributes) if (fieldsToDisplay.Contains(item.Key)) attributesToDisplay[item.Key] = item.Value; if (result.LayerId == 4) IdentifyDetailsDataGrid.ItemsSource = feature.Attributes; IdentifyDetailsDataGrid.ItemsSource = attributesToDisplay; if (result.LayerId == 9) IdentifyDetailsDataGrid2.ItemsSource = feature.Attributes; IdentifyDetailsDataGrid2.ItemsSource = attributesToDisplay; if (result.LayerId == 14) IdentifyDetailsDataGrid3.ItemsSource = feature.Attributes; IdentifyDetailsDataGrid3.ItemsSource = attributesToDisplay; }
public void ShowFeatures(List<IdentifyResult> results) { _dataItems = new List<DataItem>(); if (results != null && results.Count > 0) { //IdentifyComboBox.Items.Clear(); foreach (IdentifyResult result in results) { var temp = new Dictionary<string, object>(); var fields = new List<string>() { "School Name", "Address", "Zip", "Phone", "Website", "School District" }; //fields to display foreach (var item in feature.Attributes) { if (fields.Contains(item.Key)) temp[item.Key] = item.Value; } Graphic feature = result.Feature; string title = result.Value.ToString() + " (" + result.LayerName + ")"; _dataItems.Add(new DataItem() { Title = title, Data = temp }); //IdentifyComboBox.Items.Add(title); if (result.LayerId == 4) IdentifyDetailsDataGrid.ItemsSource = feature.Attributes; if (result.LayerId == 9) IdentifyDetailsDataGrid2.ItemsSource = feature.Attributes; if (result.LayerId == 14) IdentifyDetailsDataGrid3.ItemsSource = feature.Attributes; }
public void ShowFeatures(List<IdentifyResult> results) { _dataItems = new List<DataItem>(); if (results != null && results.Count > 0) { //IdentifyComboBox.Items.Clear(); foreach (IdentifyResult result in results) { Graphic feature = result.Feature; var temp = new Dictionary<string, object>(); var fields = new List<string>() { "School Name", "Address", "Zip", "Phone", "Website", "School District" }; //fields to display foreach (var item in feature.Attributes) { if (fields.Contains(item.Key)) temp[item.Key] = item.Value; } string title = result.Value.ToString() + " (" + result.LayerName + ")"; _dataItems.Add(new DataItem() { Title = title, Data = temp }); //IdentifyComboBox.Items.Add(title); if (result.LayerId == 4) IdentifyDetailsDataGrid.ItemsSource = feature.Attributes; if (result.LayerId == 9) IdentifyDetailsDataGrid2.ItemsSource = feature.Attributes; if (result.LayerId == 14) IdentifyDetailsDataGrid3.ItemsSource = feature.Attributes; }
public void ShowFeatures(List<IdentifyResult> results) { _dataItems = new List<DataItem>(); if (results != null && results.Count > 0) { //IdentifyComboBox.Items.Clear(); foreach (IdentifyResult result in results) { Graphic feature = result.Feature; string title = result.Value.ToString() + " (" + result.LayerName + ")"; _dataItems.Add(new DataItem() { var temp = new Dictionary<string, object>(); var fields = new List<string>() { "School Name", "Address", "Zip", "Phone", "Website", "School District" }; //fields to display foreach (var item in feature.Attributes) { if (fields.Contains(item.Key)) temp[item.Key] = item.Value; } Title = title, Data = temp }); //IdentifyComboBox.Items.Add(title); if (result.LayerId == 4) IdentifyDetailsDataGrid.ItemsSource = feature.Attributes; if (result.LayerId == 9) IdentifyDetailsDataGrid2.ItemsSource = feature.Attributes; if (result.LayerId == 14) IdentifyDetailsDataGrid3.ItemsSource = feature.Attributes; } //IdentifyComboBox.SelectedIndex = 0; } }
This is a question for REST API. I believe this is new to 10.1, in "dynamicLayers", you can specify "fields". In pre-10, you will get all fields but your Silverlight application can only show a subset of them. You can modify the following SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#IdentifyInstead of this line: Data = feature.Attributes You can create temporary variable that will hold attributesvar temp = new Dictionary<string, object>(); var fields = new List<string>() {"field1", "field2"}; //fields to display foreach(var item in feature.Attributes) { if(fields.Contains(item.Key)) temp[item.Key] = item.Value; } //more code goes here Data = temp
Data = feature.Attributes
var temp = new Dictionary<string, object>(); var fields = new List<string>() {"field1", "field2"}; //fields to display foreach(var item in feature.Attributes) { if(fields.Contains(item.Key)) temp[item.Key] = item.Value; } //more code goes here Data = temp
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.