POST
|
You are right. I worked on it and found the same solution. Now I just need to find a way to delete columns, because after each query I have one more column called �??Code�?�
... View more
06-10-2011
07:12 AM
|
0
|
0
|
415
|
POST
|
I appreciate a lot your help! I tired System.Windows.Controls.DataGrid colPED.Binding = new System.Windows.DataGrid.Binding(bindName); but it did not work: The type or namespace name 'DataGrid' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) I am posting a little bigger chunk of XAML for context. The PED grid part is on the end. <!-- Query Panel --> <userControls:GlassPanel x:Name="AllQueryPanel" Grid.Row="1" IsOpen="False" HorizontalAlignment="Right" VerticalAlignment="Top" IsResizeable="True" > <StackPanel Orientation="Vertical"> <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,15,0" > <Rectangle Stroke="Gray" RadiusX="10" RadiusY="10" Fill="#77919191" Margin="0,0,0,5" > <Rectangle.Effect> <DropShadowEffect/> </Rectangle.Effect> </Rectangle> <Rectangle Fill="#DDFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" /> <!--Outer Stack panel--> <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="30,20,30,30"> <!--SELECT QUERIES COMBO BOX --> <!--Map Layer Query Stack panel--> <StackPanel Name="stkLayerQuery" Visibility="Visible" Orientation="Horizontal" HorizontalAlignment="Left" > <TextBlock Text="Select a Map Layer: " TextAlignment="Right" Margin="3" /> <ComboBox Name="cmboLayerQuery" Width="150" SelectionChanged="cmboLayerQuery_SelectionChanged" Margin="5"> <ComboBoxItem Content="School"></ComboBoxItem> <ComboBoxItem Content="PED"></ComboBoxItem> <ComboBoxItem Content="Street"></ComboBoxItem> <ComboBoxItem Content="School District"></ComboBoxItem> </ComboBox> </StackPanel> <!--Some other code for doing queries and displaing results for different layers --> <!-- Query for PED --> <!-- Query PED by OPT code --> <StackPanel Name="stkPED" Visibility="Collapsed" > <Grid> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <TextBlock Text="OPT Code(s): " TextAlignment="Right" HorizontalAlignment="Right" VerticalAlignment="Bottom" Grid.Row="0" Grid.Column="0" Margin="3" /> <TextBox x:Name="InputPED" Text="" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" Width="100" Margin="3" KeyDown="TextBoxEnterKey_KeyDown"/> <Button x:Name="PEDQueryButton" Content="Query" Width="80" HorizontalAlignment="Center" Grid.Row="1" Grid.Column="0" Click="PEDQueryButton_Click" Margin="3"></Button> <Button x:Name="PEDClearQueryButton" Content="Clear" Width="80" HorizontalAlignment="Center" Grid.Row="1" Grid.Column="1" Click="PEDClearButton_Click" Margin="3"></Button> <Button x:Name="PEDCodeClearAllQueryButton" Content="Clear All" Width="80" HorizontalAlignment="Center" Grid.Row="1" Grid.Column="2" Click="ClearAllQueryButton_Click" Margin="3"></Button> </Grid> </StackPanel> </StackPanel> </Grid> <!�??And finally Grid for displaying PED query results--> <!-- PED Query Results Data Grid Stack panel--> <Grid x:Name="PEDQueryResultPanelGrid" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,15,15" Visibility="Collapsed"> <Rectangle Stroke="Gray" RadiusX="10" RadiusY="10" Fill="#77919191" Margin="0,0,0,5" > <Rectangle.Effect> <DropShadowEffect/> </Rectangle.Effect> </Rectangle> <Rectangle Fill="#FFFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,17,10,15" /> <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="10,2,15,15"> <TextBlock HorizontalAlignment="Left" Text="Streets Found" Foreground="White" FontSize="9" FontWeight="Bold" Margin="2,0,0,5" /> <slData:DataGrid x:Name="PEDQueryNewDataGrid" AutoGenerateColumns="False" HeadersVisibility="Column" Background="White" IsReadOnly="True" Canvas.Left="10" Canvas.Top="50" MaxHeight="150" Width="315" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" CanUserSortColumns="True" RowStyle="{StaticResource HighLightRow}" SelectionChanged="QueryHighlightDataGrid_SelectionChanged" LoadingRow="QueryHighlightDataGrid_LoadingRow"> <slData:DataGrid.Columns> <slData:DataGridTextColumn CanUserSort="True" Width="200" Binding="{Binding Attributes[Street]}" Header="Street Name"/> <slData:DataGridTextColumn CanUserSort="True" Width="80" Binding="{Binding Attributes[FromLeft]}" Header="From Left"/> <slData:DataGridTextColumn CanUserSort="True" Width="80" Binding="{Binding Attributes[ToLeft]}" Header="To Left"/> <slData:DataGridTextColumn CanUserSort="True" Width="81" Binding="{Binding Attributes[FromRight]}" Header="From Right"/> <slData:DataGridTextColumn CanUserSort="True" Width="80" Binding="{Binding Attributes[ToRight]}" Header="To Right"/> </slData:DataGrid.Columns> </slData:DataGrid> </StackPanel> </Grid> <!-- Some other code for results from other queries -- > </StackPanel> </userControls:GlassPanel>
... View more
06-10-2011
06:53 AM
|
0
|
0
|
415
|
POST
|
I could be wrong but I think the binding is interpreted literally in the XAML, so it's looking for an attribute name 'S_ + InputPED.Text' in your underlying data. Maybe in the Loaded event for the datagrid you can do something like this - In the XAML remove the column from the grid in the code behind
string bindName = "Attributes[S_" + InputPED.Text + "]";
DataGridTextColumn colPED = new DataGridTextColumn();
colPED.Header = "Code";
colPED.CanUserSort = true;
colPED.Width = new DataGridLength(50);
colPED.Binding = new Binding(bindName);
// assuming the datagrid is called gridData - replace with the name of your datagrid
gridData.Columns.Add(colPED);
Thanks for your answer! I changed one line colPED.Binding = new Binding(bindName); to colPED.Binding = new System.Windows.Data.Binding(bindName); because of an error: The type or namespace name 'Binding' could not be found (are you missing a using directive or an assembly reference?) but I am still not there. I have an error for this line: PEDQueryResultPanelGrid.Columns.Add(colPED); 'System.Windows.Controls.Grid' does not contain a definition for 'Columns' and no extension method 'Columns' accepting a first argument of type 'System.Windows.Controls.Grid' could be found (are you missing a using directive or an assembly reference?) I am using in XAML data grid and I am not sure that this error is about using data grid (should I use different kind of grid?) or I am missing something else in my code. I tried to use regular grid <Grid x:Name="PEDQueryNewDataGrid" Grid.Row="10" Grid.Column="0"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="*" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Grid.Column="0" Text="Code" Margin="10" HorizontalAlignment="Left" VerticalAlignment="Center"/> </Grid> But this did not solve my problem. Any ideas?
... View more
06-10-2011
05:53 AM
|
0
|
0
|
415
|
POST
|
I am using data grid to display a query results. Five of my fields are always the same, by the last one depends from the user input; for example, when user enters 01001 (InputPED.Text), I would like to display values for the column called ???S_01001???. Saying this I would like to be able bind my DataGridTextColumn to different fields. Here is like my code looks like now: <slData:DataGrid.Columns> <slData:DataGridTextColumn CanUserSort="True" Width="200" Binding="{Binding Attributes[Street]}" Header="Street Name"/> <slData:DataGridTextColumn CanUserSort="True" Width="80" Binding="{Binding Attributes[FromLeft]}" Header="From Left"/> <slData:DataGridTextColumn CanUserSort="True" Width="80" Binding="{Binding Attributes[ToLeft]}" Header="To Left"/> <slData:DataGridTextColumn CanUserSort="True" Width="81" Binding="{Binding Attributes[FromRight]}" Header="From Right"/> <slData:DataGridTextColumn CanUserSort="True" Width="80" Binding="{Binding Attributes[ToRight]}" Header="To Right"/> <slData:DataGridTextColumn CanUserSort="True" Width="50" Binding="{Binding Attributes[S_ + InputPED.Text]}" Header="Code"/> </slData:DataGrid.Columns> The last data grid do not returns any results to my grid. How I can bind to different fields each time?
... View more
06-09-2011
08:18 AM
|
0
|
8
|
2680
|
POST
|
Thanks Ali. Problem solved. You are correct. The grid selection is automatically shown on the map. Plus I found the Export to Excel routine I had previously used with the regular silverlight datagrid also works with the featuredatagrid. I am looking for the way to export data from Data Grid to Excel. You suggested in your post that you have a routine how to do it. Could you explain me how to approach this issue?
... View more
06-08-2011
06:40 AM
|
0
|
0
|
512
|
POST
|
You were right Terry: it was extra space added by Clear button. I took it off and everything works fine. Thanks!
... View more
06-08-2011
05:49 AM
|
0
|
0
|
173
|
POST
|
My map application has ability to do different queries on different layers. I have one button to create query on selected layer and other one to clear query results. For all layers but one Clear button works fine. If I query PED layer and press Clear after this, it gives me an error: Invalid Operation Exception was unhandled by user code. URL is not set. pointing out to the following line of code: queryTask.ExecuteAsync(query); If I query different layer ??? for example Street and press Clear button, I can query again Streets, but not PED (I receive the same error like above). If I query PED and use Delete button from keyboard to delete entered value, I can query new value without any problem. It looks like Clear button permanently disables my query on PED layer and I have no idea why. Bellow is corresponding code. Any ideas highly appreciated private void CreateQuery() { //varibles to use in case string strQueryTaskURL = ""; string strQueryWhereClause = ""; switch (_strLayerQuery) { case "PED": if (InputPED.Text.StartsWith("01") || InputPED.Text.StartsWith("02")) { strQueryTaskURL = _strPEDmnQueryService; } else if (InputPED.Text.StartsWith("07") || InputPED.Text.StartsWith("08???)) { strQueryTaskURL = _strPEDbxQueryService; } strQueryWhereClause = "S_" + InputPED.Text + " = 'A' OR S_" + InputPED.Text + " = 'B'OR S_" + InputPED.Text + " = 'C'"; break; case "Street": strQueryTaskURL = _strStreetQueryService; strQueryWhereClause = "Street LIKE '%" + InputStreetLion.Text + "%'"; break; } ESRI.ArcGIS.Client.Tasks.QueryTask queryTask = new QueryTask(strQueryTaskURL); queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted; queryTask.Failed += QueryTask_Failed; ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query(); query.ReturnGeometry = true; query.OutFields.Add("*"); query.Where = strQueryWhereClause; queryTask.ExecuteAsync(query); } private void PEDClearButton_Click(object sender, RoutedEventArgs e) { //clear PED textbox InputPED.Text = " "; // Clear previous results GraphicsLayer graphicsLayer = Map.Layers["PEDGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); } private void StreetClearButton_Click(object sender, RoutedEventArgs e) { //clear the data grid StreetQueryNewDataGrid.ItemsSource = null; StreetQueryResultPanelGrid.Visibility = Visibility.Collapsed; //clear search text box InputStreetLion.Text = ""; // Clear previous results GraphicsLayer graphicsLayer = Map.Layers["LionGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); }
... View more
06-07-2011
10:47 AM
|
0
|
3
|
836
|
POST
|
Thanks a lot! I tried the first solution and it works perfectly.
... View more
06-07-2011
09:42 AM
|
0
|
0
|
121
|
POST
|
Due to size of data I divided my dataset into five feature classes and published five different map services. Now I would like to call specific map service depending from the user input in a text box (InputPED.Text). For example all my fields beginning from 01, and 02 are included in MN map service, when 07 and 08 in BX. So if user types 01002 (or any other number beginning from 01), I would like to call and display MN, but when this is 07001 ??? BX. At first I tried following expression: if (InputPED.Text == "01002") { strQueryTaskURL = "url of my MN map service??? } And it worked fine. Later I tried to solve the problem in the following way: //MN if (InputPED.Text == " '01%' OR '02%'") { strQueryTaskURL = "url of my MN map service??? } //BX else if (InputPED.Text == "'07%' OR '08%' ") { strQueryTaskURL = "url of my BX map service??? } And none of map services url???s was selected. Instead I received an error: ???Invalid Operation Exception was unhandled by user code. URL is not set???. So I tried use LIKE if (InputPED.Text "LIKE'01% OR '02%'") { strQueryTaskURL = "url of my MN map service??? } But it gives me four errors referring to line if (InputPED.Text "LIKE'07% OR '08%'"): 1. ) expected, 2. Invalid expression term ???)???, 3. and 4. ; expected. I also tried to use Booleans: string sOptForPED = InputPED.Text.ToString().Trim(); bool bOptForPED = Convert.ToBoolean(sOptForPED); if (bOptForPED "LIKE '01%'") { strQueryTaskURL = "url of my MN map service??? } And received errors like above ( ) expected, 2. Invalid expression term ???)???, 3. and 4. ; expected). I tried to use other wild cards ???LIKE ???01#???, ???LIKE ???01*??? and nothing. Does anyone have any idea how to solve this problem?
... View more
06-06-2011
07:46 AM
|
0
|
2
|
602
|
POST
|
It turned out to be more complicated than it looked at the first glance. I used this part suggested on the forum: private void StreetNameTextBox_LostFocus(object sender, RoutedEventArgs e) { Query query = new Query() { ReturnIdsOnly = true }; query.Where = string.Format("LAST_Street like '%{0}%'", StreetNameTextBox.Text.Trim()); query.OutFields.Add("LAST_Street"); queryTask.ExecuteAsync(query); } And on this customer support helped me: void QueryTask_ExecuteRelationshipQueryCompleted(object sender, RelationshipEventArgs e) { RelationshipResult pr = e.Result; if (pr.RelatedRecordsGroup.Count == 0) { RelatedRowsDataGrid.ItemsSource = null; } else { IList<Graphic> y = new List<Graphic>(); var i = 0; foreach (var pair in pr.RelatedRecordsGroup) { foreach (var res in pair.Value) { Graphic gra = res as Graphic; y.Insert(i, gra); } } RelatedRowsDataGrid.ItemsSource = y; } } I hope this can help with your problem.
... View more
05-25-2011
04:52 AM
|
0
|
0
|
324
|
POST
|
Thank you for the examples. I was able to check that my queries work just fine on the REST, but the relationship query still doesn�??t work inside my code and I can�??t figure out why. I just opened a ticket with technical support and I hope to hear back soon.
... View more
04-25-2011
04:38 AM
|
0
|
0
|
324
|
POST
|
Thanks a lot for your suggestions! Yes, I would like to query in the same time my streets and related to them alternate names without any mouse click event. I added to my code: private void StreetNameTextBox_LostFocus(object sender, RoutedEventArgs e) { Query query = new Query() { ReturnIdsOnly = true }; query.Where = string.Format("LAST_Street like '%{0}%'", StreetNameTextBox.Text.Trim()); query.OutFields.Add("LAST_Street"); queryTask.ExecuteAsync(query); } (LAST_Street is the field name in my feature class, which I query in order to return street name; StreetNameTextBox is a text box, where I enter street name to find using query task) And changed: private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) //some other code case "Lion": strQueryGraphicsLayer = "LionGraphicsLayer"; break; // more code Which only query my Lion streets to: private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) //some other code case "Lion": strQueryGraphicsLayer = "LionGraphicsLayer"; FeatureSet newFeatureSet = args.FeatureSet; RelationshipParameter relationshipParameters = new RelationshipParameter() { ObjectIds = newFeatureSet.ObjectIDs.Cast<int>(), OutFields = new string[] { "Street" }, RelationshipId = 1, OutSpatialReference = Map.SpatialReference }; queryTask.ExecuteRelationshipQueryAsync(relationshipParameters); LionQueryResultPanel.Visibility = System.Windows.Visibility.Visible; break; //more code In order to query Lion streets and alternate names associated with these streets. (Street is a field name in a related table. I would like that after query LAST_Street, I can see also corresponding errors from Street field) Here is corresponding part of XAML: <slData:DataGrid x:Name="RelatedRowsDataGrid" AutoGenerateColumns="False" HeadersVisibility="Column" Background="White" IsReadOnly="True" Canvas.Left="10" Canvas.Top="50" Height="115" Width="996" HorizontalScrollBarVisibility="Hidden"> <slData:DataGrid.Columns> <slData:DataGridTextColumn Width="600" Binding="{Binding Attributes[LAST_Street]}" Header="Street Name"/> <slData:DataGridTextColumn Width="396" Binding="{Binding Attributes[Street]}" Header="Alternate Name"/> </slData:DataGrid.Columns> </slData:DataGrid> I also have this part of code from sample: void QueryTask_ExecuteRelationshipQueryCompleted(object sender, RelationshipEventArgs e) { RelationshipResult pr = e.Result; if (pr.RelatedRecordsGroup.Count == 0) { RelatedRowsDataGrid.ItemsSource = null; } else { foreach (var pair in pr.RelatedRecordsGroup) { RelatedRowsDataGrid.ItemsSource = pair.Value; } } } But I am able only to query LAST_Street and relationship query fails with error: �??Query failed: ESRI.ArcGIS.Client.Tasks.ServiseException: Unable to complete operation.�?� Do you have any suggestions what possible can be wrong with my code?
... View more
04-18-2011
11:01 AM
|
0
|
0
|
324
|
POST
|
I would like to show inside a grid selected street (this works fine) and corresponding to this street alternate names (here I have the problem). I tried to modify Query Related Records sample from the resource center http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#QueryRelatedRecords, but I did not fully succeeded in this task. In this example user can select point on the map by mouse (I am selecting my street by a query) and when the point is displayed in a grid, one may click on its description and display related features. private void SelectedWellsTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) { if (e.OldValue != null) { Graphic g = e.OldValue as Graphic; g.UnSelect(); g.SetZIndex(0); } if (e.NewValue != null) { Graphic g = e.NewValue as Graphic; g.Select(); g.SetZIndex(1); //Relationship query RelationshipParameter relationshipParameters = new RelationshipParameter() { ObjectIds = new int[] {Convert.ToInt32(g.Attributes[SelectedWellsTreeView.Tag as string])}, OutFields = new string[] { "OBJECTID, API_NUMBER, ELEVATION, FORMATION, TOP" }, RelationshipId = 3, OutSpatialReference = MyMap.SpatialReference }; queryTask.ExecuteRelationshipQueryAsync(relationshipParameters); } } I would like that my related alternate names display in the same time as selected street without any clicking like above. Here I query streets: private void createQuery() { //some other code// case "Lion": strQueryTaskURL = "my server address/lion_relate/MapServer/0" strQueryWhereClause = "LAST_Street LIKE '%" + StreetNameTextBox.Text + "%'"; break; //more code } I am trying to change it to: private void createQuery() { //some other code// case "Lion": strQueryTaskURL = "my server address/lion_relate/MapServer/0" strQueryWhereClause = "LAST_Street LIKE '%" + StreetNameTextBox.Text + "%'"; if (strQueryWhereClause != null) { //but I have problem to add relationship here } break; //more code } Any suggestions how to make this work?
... View more
04-13-2011
12:10 PM
|
0
|
7
|
1286
|
POST
|
Thank you for your answer. I was able solve the problem in the following way: private void TextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { e.Handled = true; //do my query } }
... View more
03-31-2011
06:05 AM
|
0
|
0
|
199
|
Online Status |
Offline
|
Date Last Visited |
01-12-2024
07:54 AM
|