Forum Discussion

jwoodard's avatar
jwoodard
Cloud Apps
09-29-2022
Solved

Sort BloX Widget Carousel by Value

I am looking to find a way to use a widget script to override the sort logic for a BloX Carousel.  Use Case: I am displaying the Top 10 agents for a company and wish to sort by the production rank ...
  • harikm007's avatar
    harikm007
    09-30-2022

    Hope this script works. This is to sort blox by Values.  (here 2 is the index of Rank panel in your screenshot)

    
    widget.on('queryend',function(se,ev){
    	ev.rawResult.values.sort(function(a, b){
    		var aValue = a[2].data;
    		var bValue = b[2].data;
    						
    		if (aValue < bValue)
    			return -1;
    		if (aValue > bValue)
    			return 1;
    							
    		return 0;
    	})
    })

     

     

    Just curious to know - Does the value panel's sorting not work?

    -Hari