[GIS] Displaying unique records in combo-box in ArcGIS API for JavaScript

arcgis-10.1arcgis-javascript-apiarcgis-server

I am displaying almost 9000 records by four type (A,B,C & D) in which I am displaying records using combo-box.

Each record is classified by "ctype" ( A or B or C or D) so I am putting this in combo so that If I select type A then all records of type A will be display..

Code that I am following :

Code link : http://jsfiddle.net/sunilspalkar/hdmNx/1/

In above code all records displaying but its not showing unique records of dam . I am facing same problem..

What I tried :

1.I am using query layer & I can not use "distinct" because of "geom" column .
2.I searched the API reference also for "unique elements for combo-box" but I did not found suitable material.
3. I found this link In this link values are hard coded and I have dynamic values.
4. If I use "STATE" column instead of "ctype" then it works fine.. the "ctype" column has string type and all records are well formatted..

Software's : Sql Server 2008 r2 (for query layer) , ArcGIS Server/Desktop 10.1 , Java script API ver. 3.0/3.1

Best Answer

I assume you want the list to show a list of unique dam values? You need to filter your array to get them. Here is a fiddle http://jsfiddle.net/dave_wilton/hdmNx/6/

It assumes you are using name to filter on:

    function cleanFilterValues(values) {
      var unique = {};
      //get rid of duplicates
      return dojo.filter(values, function(value) {
             if (!unique[value.name]) {
             unique[value.name] = true;
             return true;
       }
     return false;
    });