Select to view content in your preferred language

Identify vs Query

795
3
12-29-2010 09:21 AM
JayKappy
Frequent Contributor
In my app I fire off some code "On Map Click"...it does an identify on a few layers and returns the results into 4 different reesult boxes.  THis works great...

I then started looking at a Search/Query.  I added the example from ESRI API Silverlight.  I modified it a bit to look at my dataset.  The combobox is populated with the correct values and when changed it returns and displays the attributes...

What I want to do now is figure out how to push these values to a different results box.  I am pretty confused because one is working off the premise of a mouse click on the map (identify) and the other is a query basaed method grabbing the correct record from a drop down change.

Identify Example:
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Identify

Attribute Query Example:
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#AttributeQuery

I am trying to figure out if it is possible to do a search in the Attribute Query and have the results show up in another results panel or grid....Can I do this...if so any pointers...

Maybe I can paste some of my code?

THanks
0 Kudos
3 Replies
AliMirzabeigi
Emerging Contributor
I guess what you are trying to achieve is to show the results in a different panel in the same page?? If so, then you would just need to place your DataGrid control in a desired panel (QueryDetailsDataGrid in that SDK sample) and leave the rest of the code as-is.
0 Kudos
JMcNeil
Deactivated User
Jay, it is definitely possible.  I have all my queries (attribute searches and/or spatial selects) sent one grid, which is different then the examples.  I'm using the FeatureDataGrid
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureDataGrid
It is much nicer and has some good features - record scrolling, field sorting, switch selection, etc.

Like Ali stated it is mainly in your xaml

Currently the grid is "QueryGrid"
 <Grid x:Name="QueryGrid" HorizontalAlignment="Right" VerticalAlignment="Top" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="30" />
                    <RowDefinition Height="30" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <TextBlock x:Name="DataDisplayTitleBottom" Text="Query a layer (search for a state)" 
                       Foreground="White" FontSize="10" Grid.Row="0"                      
                       Margin="15,5,15,1" HorizontalAlignment="Center" >
                    <TextBlock.Effect>
                        <DropShadowEffect />                          
                    </TextBlock.Effect>
                </TextBlock>
                <ComboBox x:Name="QueryComboBox" Grid.Row="1" MinWidth="150" SelectionChanged="QueryComboBox_SelectionChanged"
                         Margin="5,1,5,5" >
                </ComboBox>
                <ScrollViewer x:Name="DataGridScrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto"  
                         Width="230" MinHeight="200" Visibility="Collapsed" Grid.Row="2">
                    <slData:DataGrid x:Name="QueryDetailsDataGrid" AutoGenerateColumns="False" HeadersVisibility="None" 
                              Background="White">
                        <slData:DataGrid.Columns>
                            <slData:DataGridTextColumn Binding="{Binding Path=Key}" FontWeight="Bold"/>
                            <slData:DataGridTextColumn Binding="{Binding Path=Value}"/>
                        </slData:DataGrid.Columns>
                    </slData:DataGrid>
                </ScrollViewer>
            </Grid>





Just move this code to another grid: and your table will appear in a different gird...grab the scrollviewer if you want that.

                    <slData:DataGrid x:Name="QueryDetailsDataGrid" AutoGenerateColumns="False" HeadersVisibility="None" 
                              Background="White">
                        <slData:DataGrid.Columns>
                            <slData:DataGridTextColumn Binding="{Binding Path=Key}" FontWeight="Bold"/>
                            <slData:DataGridTextColumn Binding="{Binding Path=Value}"/>
                        </slData:DataGrid.Columns>
                    </slData:DataGrid>



Now if you are talking about sending it to a different grid like the identify grid then change the code behind.  Search for these two lines:

QueryDetailsDataGrid.ItemsSource = selectedFeature.Attributes;

QueryDetailsDataGrid.ItemsSource = null;


To something like

IdentifyDetailsDataGrid.ItemsSource = selectedFeature.Attributes;

IdentifyDetailsDataGrid.ItemsSource = null;




Not 100% if that will work but I'm thinking it should if you have the identify code in the same app as the query code...I just quickly glanced and didn't write or test it in V.S.

J
0 Kudos
JayKappy
Frequent Contributor
Was laying in bed last night and what you explained morphed in my brain...
Simply move the return window into another grid...couldnt wait to get to work today
Then how to target a couple different grids....hmmmm
Was confusing me because I was updating one results panel with BOTH the search and identify....

I cant thank you enough for your thoughts and help....this is exactly what I needed...

I have a couple different Grids in my XAML page...I then simple targeted those on the Search

THANKS AGAIN FOR YOUR HELP.....HAVE A GREAT NEW YEAR....:D


'.Snip
            IdentifyDetailsDataGrid6.DataContext = selectedFeature.Attributes

            IdentifyDetailsDataGrid5.DataContext = selectedFeature.Attributes
'.Snip

'.Snip

            If DataGridScrollViewer.Visibility = Visibility.Collapsed Then
                DataGridScrollViewer.Visibility = Visibility.Visible
                QueryGrid.Height = Double.NaN
                QueryGrid.UpdateLayout()
            End If

            If IdentifyResultsPanel5.Visibility = Visibility.Collapsed Then
                IdentifyResultsPanel5.Visibility = Visibility.Visible
                IdentifyGrid5.Height = Double.NaN
                IdentifyGrid5.UpdateLayout()
            End If

        Else
            DataGridScrollViewer.DataContext = Nothing
            DataGridScrollViewer.Visibility = Visibility.Collapsed
            QueryGrid.Height = Double.NaN
            QueryGrid.UpdateLayout()

            IdentifyResultsPanel5.DataContext = Nothing
            IdentifyResultsPanel5.Visibility = Visibility.Collapsed
            IdentifyGrid5.Height = Double.NaN
            IdentifyGrid5.UpdateLayout()

'.Snip
0 Kudos