Select to view content in your preferred language

FindTask Live Search

1252
6
01-17-2012 04:18 AM
Salomon_VágadalJoensen
Deactivated User
How do I implement a Live Search functionality into this http://help.arcgis.com/en/webapi/javascript/arcgis/demos/find/find_map_datagrid.html sample?

I've looked around the Web a bit, and I'm at loss where to start.
0 Kudos
6 Replies
derekswingley1
Deactivated User
What is "Live Search"?
0 Kudos
Salomon_VágadalJoensen
Deactivated User
With Live Search, I mean a search box that returns an updated search result in a drop-down box for every key-press. Think Google's suggestion box returned from the user's typing. IDK if this is clear enough.
0 Kudos
Salomon_VágadalJoensen
Deactivated User
Well, I've worked out how to do it, but it still needs more work.

I've used Query to do it, to get query results from the server. I got most of the functionality and setup from this sample:

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/query_nomap.html

Where I use esri.tasks.Query to query the MapServer for results


  function queryResults(results) {
   queryHaldari = queryFilter(results);
   
   console.log(queryHaldari);
   
   s = "";
   for (var i=0, il=queryHaldari.length; i<il; i++) {
     
    s = s + "<div><b>Veganavn:</b> " + queryHaldari[0].attributes.veganavn + ", <b>Bygd:</b> " + queryHaldari[0].attributes.bygd_1 + "<br /></div>";

   }
   dojo.byId("searchList").innerHTML = s;
  }

  function queryResults2(results) {
   queryHaldari = queryFilter(results);

   console.log(queryHaldari);
   
   for (var i=0, il=queryHaldari.length; i<il; i++) {
     
    s = s + "<div><b>Veganavn:</b> " + queryHaldari[0].attributes.veganavn + ", <b>Bygd:</b> " + queryHaldari[0].attributes.bygd_1 + "<br /></div>";

   }
   dojo.byId("searchList").innerHTML = s;
  }
  


This is the main component, nevermind the other function calls.

Now I'm trying to get more functionality to s and give it like onmouseover and onmouseout and onclick, but I'm uncertain on how to add that programmatically.
0 Kudos
Marie-GilSeptfonds
Emerging Contributor
Hello,

In the past I've tried to implement an autocomplete (live search ?) for searching an adress which is updated at any key pressed.

I didn't find a solution with a Mapservice.

The only one solution I've found, is to use a PHP wich sends a request to my Database (Oracle) and return the response in a json format.
This Json is formatted for a dojox.data.QueryReadStore which is conected dijit.form.FilteringSelect.

[ATTACH=CONFIG]11321[/ATTACH]
0 Kudos
Salomon_VágadalJoensen
Deactivated User
Nice, that is somewhat I want it to look like; now I send the results to a div that I format programmatically and it's quite ugly compared to your method.
0 Kudos
Salomon_VágadalJoensen
Deactivated User
This is how it looks now, I'm pretty happy with how it turned out, I just need to do some CSS and add onclick, onfocus and make it able to scroll between autocomplete (live search) results.
0 Kudos