Select to view content in your preferred language

How to zoom to a selected record after click in a popup DataGrid

721
2
09-15-2010 11:16 PM
varnavarna
Emerging Contributor
Hi,

We are trying to make a popup DataGrid to be clickable and center the map on the selected parcel. I'm trying to modify the code from those two great threads --> http://forums.arcgis.com/threads/10377-How-to-zoom-to-selected-record-on-Data-Grid-result?p=35685&po... and http://forums.arcgis.com/threads/11765-How-to-make-mouserover-on-map-amp-highlight-popup-datagrid?p=...

There is a problem with communication between the application and the popup window. There is a click event in the DataGrid which leads to this function:

private function sfDataGrid_Click():void
            {
                var obj:Object = sfDataGrid.selectedItem;
                if (obj != null)
                {
                    lastIdentifyResultGraphic = null;
                    
                    query.where = "STATE_NAME = '" + obj["STATE_NAME"] + "'"
                    queryTaskZoom.execute(query, new AsyncResponder(onResult, onFault));
                    function onResult(featureSet:FeatureSet, token:Object = null):void
                    {
                        lastIdentifyResultGraphic = featureSet.features[0];
                        lastIdentifyResultGraphic.symbol = sfs;
                        MainMap.extent = new Extent(lastIdentifyResultGraphic.geometry.extent.xmin,lastIdentifyResultGraphic.geometry.extent.ymin,lastIdentifyResultGraphic.geometry.extent.xmax,lastIdentifyResultGraphic.geometry.extent.ymax);
                    }
                    function onFault(info:Object, token:Object = null):void
                    {
                        Alert.show(info.toString(), "Query Problem");
                    }
                }
            }


but when I click in the popup while debugging I get a "TypeError: Error #1009: Cannot access a property or method of a null object reference." at component

query.where = "STATE_NAME = '" + obj["STATE_NAME"] + "'"


Any ideas what we are doing wrong?

Thank you!
Tags (2)
0 Kudos
2 Replies
varnavarna
Emerging Contributor
Hey!

I was able to find a solution to the problem.

I used the parentApplication property in the query and queryTaskZoom and it started transfering the clicks in the main App

Here is the changed function:

private function sfDataGrid_Click():void
            {
                var obj:Object = resultsGrid.selectedItem;
                if (obj != null)
                {
                    lastIdentifyResultGraphic = null;
                    
                    parentApplication.query.where = "Owner_Name = '" + obj["Owner_Name"] + "'"
                    parentApplication.queryTaskZoom.execute(parentApplication.query, new AsyncResponder(onResult, onFault));
                    function onResult(featureSet:FeatureSet, token:Object = null):void
                    {
                        lastIdentifyResultGraphic = featureSet.features[0];
                        lastIdentifyResultGraphic.symbol = sfs;
                        parentApplication.myMap.extent = new Extent(lastIdentifyResultGraphic.geometry.extent.xmin,lastIdentifyResultGraphic.geometry.extent.ymin,lastIdentifyResultGraphic.geometry.extent.xmax,lastIdentifyResultGraphic.geometry.extent.ymax);
                    }
                    function onFault(info:Object, token:Object = null):void
                    {
                        Alert.show(info.toString(), "Query Problem");
                    }
                }
                
            }
0 Kudos
AyieKepong
Emerging Contributor
gisvarna,

I already tried the code above but there still has a problem with communication between the application and the popup window. No selected record zooming after click in the popup DataGrid.

Please let me know any ideas on how to resolve this. Any help is appreciated.
0 Kudos