Select to view content in your preferred language

datagrid and feature layer sync

1848
3
09-27-2011 02:08 PM
suharthachowdhury
New Contributor
Hi,

I have a datagrid bound to a domain data source. The data grid is populated through a RIA domain service. The feature layer is a map service which is as below:

   <esri:FeatureLayer ID="MyFeatureLayer"
      Url="XXX/MapServer/0"
      OutFields="OBJECTID, SYS_LOC_CO, X_COORD, Y_COORD, Location, Loc_type"
      Renderer="{StaticResource MySimplePointRenderer}"                             
      DisableClientCaching ="True"
      MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp">

My question is, is it possible to highlight the corrresponding row of the datagrid when the user clicks a graphic on the map? I know it is possible to do so when the datagrid is tied to the feature layer as in this example: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ToolkitFeatureDataGrid
But how do I do the same in my case?
0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
You need to synchronize by yourself the graphics selection and the datagrid selection.

There is a sample here : http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SpatialQuery
0 Kudos
suharthachowdhury
New Contributor
You need to synchronize by yourself the graphics selection and the datagrid selection.

There is a sample here : http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SpatialQuery



Hi dbroux,
Tahnk a lot for your reply. I have tried your example, but it does not work for me... 😞 Not sure what I am doing wrong. During debugging I found that, my datagrid.selectedItem is getting the reference to the selected feature layer graphic. But ScrollIntoView() is not responding for some reason... the mouse over/selected graphic is not highlighted in the datagrid. here's my method (Same as in the example):

private void FeatureLayer_MouseEnter(object sender, GraphicMouseEventArgs e)
{
    view_KMDataGrid.Focus();
    view_KMDataGrid.SelectedItem = e.Graphic;
    view_KMDataGrid.CurrentColumn = view_KMDataGrid.Columns[0];          
     //view_KMDataGrid.UpdateLayout();    // tried this too... didn't work   view_KMDataGrid.ScrollIntoView(view_KMDataGrid.SelectedItem,view_KMDataGrid.CurrentColumn);
  }

Please help what I am doing wrong.. Thanks for helping.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
You have to tweak  the sample since in your case the objects displayed in your datagrid are not the graphics displayed in the map but the objects coming from your RIA domain service (i.e it's not the same instances)
One way may be to use the 'ObjectID' to retrieve the graphics when the selection changes in the datagrid, and, viceversa, to find the row in the datagrid when the selection changes in the map.
0 Kudos