Select to view content in your preferred language

Sort InfoWindow

659
1
Jump to solution
09-12-2013 09:30 AM
NoloVegis
Deactivated User
I would like to be able to sort the records in an infowindow when multiple records are returned for an event.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
NoloVegis
Deactivated User
Figured something out for what I required for now. I have a GeoRSS feed in a cluster. I wanted the cluster graphics to keep the records in order based on date. I used the clusterWeightFunction:

public function myCalculateClusterWeightFunction(cluster:Cluster):void
   {
    var g:Array = cluster.graphics;
    g.sort(orderCluster);
    cluster.graphics = g;
   }
  
   private function orderCluster(a, b):int
   {
    var name1 = makeDate(a);
    var name2 = makeDate(b);
    if (name1 < name2)
    {
     return -1;
    }
    else if (name1 > name2)
    {
     return 1;
    }
    else
    {
     return 0;
    }
   }
   private function makeDate(input):int
   {
    // convert string date to a numeric date
    var result:int = 0;

    var ad:Array = input.name.split(" ");

    var x:String = ad[0].toString();
    var d:String = ad[1].toString();
    var m:String = ad[2].toString();
    var y:String = ad[3].toString();
    x = d + " " + m + " " + y;
   
    var date:Date = new Date(x);
   
    result = (date.fullYear * 10000) + (date.month * 100) + (date.date);
    return result;
   }

View solution in original post

0 Kudos
1 Reply
NoloVegis
Deactivated User
Figured something out for what I required for now. I have a GeoRSS feed in a cluster. I wanted the cluster graphics to keep the records in order based on date. I used the clusterWeightFunction:

public function myCalculateClusterWeightFunction(cluster:Cluster):void
   {
    var g:Array = cluster.graphics;
    g.sort(orderCluster);
    cluster.graphics = g;
   }
  
   private function orderCluster(a, b):int
   {
    var name1 = makeDate(a);
    var name2 = makeDate(b);
    if (name1 < name2)
    {
     return -1;
    }
    else if (name1 > name2)
    {
     return 1;
    }
    else
    {
     return 0;
    }
   }
   private function makeDate(input):int
   {
    // convert string date to a numeric date
    var result:int = 0;

    var ad:Array = input.name.split(" ");

    var x:String = ad[0].toString();
    var d:String = ad[1].toString();
    var m:String = ad[2].toString();
    var y:String = ad[3].toString();
    x = d + " " + m + " " + y;
   
    var date:Date = new Date(x);
   
    result = (date.fullYear * 10000) + (date.month * 100) + (date.date);
    return result;
   }
0 Kudos