<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:esri="http://www.esri.com/2008/ags" pageTitle="Query Task (without a map)"> <!-- Problem: How to query the server? Solution: Send the query using the execute() method on a QueryTask. This sample sets up a QueryTask (what layer on what server to query). When user clicks the "Get Details" button, a Query is sent with the user-provided text to search for. Meanwhile a DataGrid has been setup and listens for the results (using executeLastResult) from the querytask. --> <!-- Start Declarations --> <esri:QueryTask id="queryTask" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"/> <esri:Query id="query" returnGeometry="false" where="STATE_NAME = '{stateName.text}'" outFields='["STATE_NAME","STATE_FIPS","SUB_REGION","STATE_ABBR","POP2000","POP2007"]'/> <!-- End Declarations --> <mx:Panel title="Using Query tasks without maps"> <mx:HBox> <mx:Label text="US state name: " /> <mx:TextInput id="stateName" text="Colorado" /> <mx:Button label="Get Details" click="queryTask.execute(query);" /> </mx:HBox> <mx:DataGrid id="resultsGrid" dataProvider="{queryTask.executeLastResult.attributes}" visible="{queryTask.executeLastResult != null}" > <mx:columns> <mx:DataGridColumn headerText="State Name" dataField="STATE_NAME"/> <mx:DataGridColumn headerText="Region" dataField="SUB_REGION"/> <mx:DataGridColumn headerText="FIPS" dataField="STATE_FIPS"/> <mx:DataGridColumn headerText="Abbreviation" dataField="STATE_ABBR"/> <mx:DataGridColumn headerText="Population 2000" dataField="POP2000"/> <mx:DataGridColumn headerText="Population 2007" dataField="POP2007"/> </mx:columns> </mx:DataGrid> </mx:Panel> </mx:Application>
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.