+ Start a Discussion
Ola BamideleOla Bamidele 

How to add filter to Account List

Hi All, 

I this code that displays locations on a map when you click the account name in the account list at the bottom of the page. 

So I was wondering, is it possible to add a filter to the list? So maybe it can be sorted in alphabetical order or filter the account based on something?

Please if you know how then please let me know please!

This is my code:
    jsLoaded: function(component, event, helper) {
        var map = L.map('map', {zoomControl: false, tap: false}).setView([37.784173, -122.401557], 14);
                attribution: 'Tiles © Esri'
        component.set("v.map", map);

accountsLoaded: function(component, event, helper) {
        // Add markers
        var map = component.get('v.map');
        var accounts = event.getParam('accounts');
        for (var i=0; i<accounts.length; i++) {
            var account = accounts[i];
            var latLng = [account.Location__Latitude__s, account.Location__Longitude__s];
            L.marker(latLng, {account: account}).addTo(map)
            // To display account name and status in the text balloon
accountSelected: function(component, event, helper) {
        // Center the map on the account selected in the list
        var map = component.get('v.map');
        var account = event.getParam("account");
        map.panTo([account.Location__Latitude__s, account.Location__Longitude__s]);


Thank you very much!
Ola BamideleOla Bamidele
I think I may have posted the wrong part of my code that needs to be edited for this the filter to be active, I think this is the relevant piece of code:
public with sharing class AccountController {
    public static List<Account> findAll() {
    return [SELECT id, name, Location__Latitude__s, Location__Longitude__s, Industry
            FROM Account
            WHERE Location__Latitude__s != NULL AND Location__Longitude__s != NULL
            LIMIT 50];

Thanks very much