Select to view content in your preferred language

How to show data in a FeatureDataGrid with 1:M relationship?

745
5
01-19-2011 03:25 AM
SanajyJadhav
Deactivated User
Hi,

I am stuck on one serious issue.

I have one land parcels layer in a published feature service. And I have related this layer with one non GIS table with 1:M relationship. That means, for a single parcel, I want to fetch multiple records from non gis table and display this all data (gis + non gis) in a featureDatagrid.

I am not sure how to do this. I have found couple of code samples on the forum and tried to implement them, but no luck.

Can anybody please help me on this issue?

My functionality is quite straight forward, when user identifies the parcel in a silverlight application by clicking it, I want to display gis data (from the layers attribute table) and non gis data (from the related non gis table) in a ESRI FeatureDatagrid. And is it possible to show multiple rows for this identified feature in a featureDatagrid?

Any help would be appreciated. Sample code would be of great help.

Thanks,
Sanjay.
0 Kudos
5 Replies
JMcNeil
Deactivated User
Sanjay

So do have your datagrid in place with identify/select/query.  If so is the feature datagrid being populated with you GIS data (from the layers attribute table).  For simpilicity I would probably set this up first.  Then I would make a connection to the non GIS database maybe by RIA (if you are using SQL database), if you are Oracle it is a different story.

Any way what about creating a onclick selection on your feature grid and pass your unique ID to your outside database (Query) and then sending it back to its own seperate datagrid?  Not exactly what you are looking for but probably easier.


Here's the code you need to add to make your FeatureGrid Selection Fire (code behind)

private void FeatureDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

            var graphics = (sender as ESRI.ArcGIS.Client.Toolkit.FeatureDataGrid).SelectedGraphics;
            foreach (var g in graphics)
            {
                // get id 
                var id = g.Attributes["UniqueQueryID"];
                // TODO: retrieve outside data for this id before you write this

                //Try sending the UniqueQueryID to a textbox to see if it is working 
                PARCELIDPASS.Text = string.Format("The Parcel ID passed is {0}", id);
                break;
            }

        }





Add this to your XAML where your featuregrid is defined

SelectionChanged="FeatureDataGrid_SelectionChanged"



Add this to your xaml this is where your ParcelText ID will be passed later you can change the text passing to a new grid or table or something

 <!-- Parcel ID SHOWER-->

        <userControls:CollapsiblePanel x:Name="ParcelShower" IsExpanded="True" 
                                           RenderTransformOrigin="1,0"
                                           VerticalContentAlignment="Center" HorizontalContentAlignment="Right" Margin="0,75,10,0" Effect="{StaticResource dropShadow}" >
            <Grid Width="350" Height="80"  >
                <Border Background="{StaticResource CommonPanelBorderBackgroundBrush}" BorderBrush="{StaticResource CommonBorderBrush}" BorderThickness="1" CornerRadius="6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <Border Effect="{StaticResource miniDropShadow}" Style="{StaticResource RibbonElementBorder}" Padding="15" Margin="10" >



                        <StackPanel Canvas.Left="20" Canvas.Top="14" Margin="0,5,0,0">

                

                <TextBlock x:Name="PARCELIDPASS" Text="" Foreground="Red" FontWeight="SemiBold" Margin="0,5,0,5" HorizontalAlignment="Center" TextWrapping="Wrap"/>

               

            </StackPanel>

                    </Border>
                </Border>
                <Image Source="images/CloseX.png" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="3" Stretch="None" Cursor="Hand" ToolTipService.ToolTip="Close" >
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="MouseLeftButtonDown" >
                            <actions:ToggleCollapseAction TargetName="ParcelShower" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Image>
            </Grid>
        </userControls:CollapsiblePanel>

 
        <!-- END PARCEL SHOWER-->




That should get you started passing the ID to your outside database. 



You can check some RIA and databinding turtorial and code at MS site:

RIA CODE WALK THROUGH - http://msdn.microsoft.com/en-us/library/ee707376%28v=VS.91%29.aspx

RIA VIDEO - http://www.silverlight.net/learn/videos/all/net-ria-services-intro/

RIA VIDEO - http://www.silverlight.net/learn/videos/all/ria-services-support-visual-studio-2010/

BINDING DATA - http://www.silverlight.net/learn/videos/silverlight-videos/simple-data-binding-of-ui-to-net-classes/


Hope this helps
0 Kudos
JenniferNery
Esri Regular Contributor
This might be a related thread http://forums.arcgis.com/threads/16731-Change-value-of-FeatureDataGrid-Cell if you are also working with related tables.
0 Kudos
SanajyJadhav
Deactivated User
Thanks to J Lennon and Jennifer for their replies.

It seems that I have found the solution to the problem.ESRI recently posted a very good sample at http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#QueryRelatedRecords This sample would help me to show data from related non gis table and GIS layer at the same time.

And, thanks to ESRI for posting such a helpful sample just on time when I needed it. I would say I got lucky.

-Cheers,
Sanjay.
0 Kudos
KenCarrier
Deactivated User
This might be a related thread http://forums.arcgis.com/threads/16731-Change-value-of-FeatureDataGrid-Cell if you are also working with related tables.


This just shows how to query related tables not edit them, how can you use the FeatureDataGrid to not only show the related objects but make them editable?
0 Kudos
JenniferNery
Esri Regular Contributor
0 Kudos