Locator results to data grid / table?

1663
19
07-08-2011 01:11 AM
ChrisBuckmaster1
Occasional Contributor
Hi


I am working with a locator but would prefer the results to be outputted to a data grid / table for the user to select their desired address (if more than 1 is returned).

Cannot seem to find any samples that have implemented this, not too sure if there is anyone out there who has coded something like this?

I was thinking of using a dojo data grid (much like the find task sample) but cannot figure out how to pass the candidate results into a grid.

Any help? 🙂


Thanks
0 Kudos
19 Replies
ChrisBuckmaster1
Occasional Contributor
Hi Heming

Thanks a lot for your help with this, figured out that I need to use the geometry property just as I posted my last reply.

Thanks again! 🙂

PS - How can I give you credit for this? I cannot find a "this post answered my question" option anywhere?
0 Kudos
HemingZhu
Occasional Contributor III
Hi Heming

Thanks a lot for your help with this, figured out that I need to use the geometry property just as I posted my last reply.

Thanks again! 🙂

PS - How can I give you credit for this? I cannot find a "this post answered my question" option anywhere?


Don't mention it. Just want to help
0 Kudos
ChrisBuckmaster1
Occasional Contributor
Hi Heming

Sorry but I have stumbled upon another problem so if you fancy figuring the following out I would appreciate it! 🙂

All of my candidate addresses are coming up in the data grid and I can successfully zoom to each one which is great, but I am trying to limit the number of results that are outputted to the grid using an if statement which is used in the ESRI locator sample (the code snippet below is what I have tried to use).

I run it when the array 'items' is built to try and only select those that have a candidate score of 80 or above - my graphics layer is successfully drawing only those candidates that have a score of +80 but the data grid has an error, when using firebug it mentions that it "cannot set property '_RI' of undefined".

Digging a bit deeper this variable seems to be set in the dojo.data.ItemFileReadStore:-

this._rootItemPropName = "_RI"; // Default Item Id for isItem to attach to every item.


This might be something more dojo related but I don't suppose you have any other possible ways of limiting the candidates down by scores or indeed if the above error might be solvable?


I appreciate all the help you have given me so far! 🙂



//CODE

//create array of attributes
        var items = dojo.map(candidates,function(candidate){
  if (candidate.score > 80){
            geom = new esri.geometry.Point(candidate.location.x, candidate.location.y);
   var attributes = candidate.attributes;
   var scoreCandidate = candidate.score;
            var graphic = new esri.Graphic(geom, symbol, attributes);
            //add a graphic to the map at the geocoded location
            map.graphics.add(graphic);
            return candidate.attributes;//break out of loop after one candidate with score greater  than 80 is found.
  }
  });

//CODE
0 Kudos
HemingZhu
Occasional Contributor III
Hi Heming

Sorry but I have stumbled upon another problem so if you fancy figuring the following out I would appreciate it! 🙂

All of my candidate addresses are coming up in the data grid and I can successfully zoom to each one which is great, but I am trying to limit the number of results that are outputted to the grid using an if statement which is used in the ESRI locator sample (the code snippet below is what I have tried to use).

I run it when the array 'items' is built to try and only select those that have a candidate score of 80 or above - my graphics layer is successfully drawing only those candidates that have a score of +80 but the data grid has an error, when using firebug it mentions that it "cannot set property '_RI' of undefined".

Digging a bit deeper this variable seems to be set in the dojo.data.ItemFileReadStore:-

this._rootItemPropName = "_RI"; // Default Item Id for isItem to attach to every item.


This might be something more dojo related but I don't suppose you have any other possible ways of limiting the candidates down by scores or indeed if the above error might be solvable?


I appreciate all the help you have given me so far! 🙂



//CODE

//create array of attributes
        var items = dojo.map(candidates,function(candidate){
  if (candidate.score > 80){
            geom = new esri.geometry.Point(candidate.location.x, candidate.location.y);
   var attributes = candidate.attributes;
   var scoreCandidate = candidate.score;
            var graphic = new esri.Graphic(geom, symbol, attributes);
            //add a graphic to the map at the geocoded location
            map.graphics.add(graphic);
            return candidate.attributes;//break out of loop after one candidate with score greater  than 80 is found.
  }
  });

//CODE


The simplest approach would be setup the loactor's minium score as 80 and then publish it on the server. then you would has to deal with it using code logic.
0 Kudos
ChrisBuckmaster1
Occasional Contributor
Heming

Brilliant once again - you saved me another day of looking at dojox grid filtering so thanks a lot! 🙂
0 Kudos
ScottKearney
New Contributor II
What would the datagrid headings look like?  I get an error when trying to bind the datastore to the following datagrid:

                        <table data-dojo-type="dojox.grid.DataGrid" data-dojo-id="AddressGrid" id="AddressGrid"
                            data-dojo-props="rowSelector:''" style="width: 325px; height: 350px;
                            margin: 0; overflow: scroll">
                            <thead>
                                <tr>
                                    <th field="Match_addr">
                                        Match_addr
                                    </th>
                                    <th field="Score">
                                        Score
                                    </th>
                                    <th field="Ref_ID">
                                        Ref_ID
                                    </th>
                                </tr>
                            </thead>
                        </table>
0 Kudos
HemingZhu
Occasional Contributor III
What would the datagrid headings look like?  I get an error when trying to bind the datastore to the following datagrid:

                        <table data-dojo-type="dojox.grid.DataGrid" data-dojo-id="AddressGrid" id="AddressGrid"
                            data-dojo-props="rowSelector:''" style="width: 325px; height: 350px;
                            margin: 0; overflow: scroll">
                            <thead>
                                <tr>
                                    <th field="Match_addr">
                                        Match_addr
                                    </th>
                                    <th field="Score">
                                        Score
                                    </th>
                                    <th field="Ref_ID">
                                        Ref_ID
                                    </th>
                                </tr>
                            </thead>
                        </table>


You can create a grid structure layout in your init by the following:
  ...
  var layout = {
            cells: [
  { field: "Match_addr", name: "Match Address", width: 'auto' },
  { field: "Score", name: "Scores", width: '125px' },
                    { field: "Ref_ID", name: "Reference ID", width: '125px' }
                   ]
        };
        var grid = dijit.byId("AddressGriD");
        grid.attr("structure", layout);
        ...
0 Kudos
ScottKearney
New Contributor II
Thanks for the quick response.  I was originally using a composite locator and could not bind it and assumed my data grid was structured wrong.  However,  once I used a single locator, I could bind.  I guess the composite returns a different array structure.

Thanks again.
0 Kudos
HemingZhu
Occasional Contributor III
Thanks for the quick response.  I was originally using a composite locator and could not bind it and assumed my data grid was structured wrong.  However,  once I used a single locator, I could bind.  I guess the composite returns a different array structure.

Thanks again.


IN your locator REST entry, you could find Candidate Fields and/or Intersection Candidate Fields.

Those fields are the ones you could choose to bind.
0 Kudos
GabiVoicu
Occasional Contributor
Chris, that is exactly what I was looking for  - would you mind sharing or posting your sample in the code gallery?

Thank you
Gabi Voicu
0 Kudos