0

We have a table this is referencing the default lightning sort icons and need to replace all three(up, down, both) with different svg images from static resources.

The current code references standard utility and would like to change the references in the conditional to point to the /resources directory. If the conditional was in the component, it may be easier but it's in the controller js.

handleSort: function(component, event, helper) {
        var item = event.currentTarget;
        var cname = item.dataset.cname;
        console.log('cname = ' + cname);
        var sortIcons = component.get("v.sortIcons");
        var iconName = sortIcons[cname];
        console.log('iconName = ' + iconName);

        for (var k in sortIcons) {
            if (k != cname) {
                sortIcons[k] = 'utility:sort';
            }
        }

        var first = 0;
        var second = 0;
        if (iconName == 'utility:sort' || iconName == 'utility:arrowdown'){
            sortIcons[cname] = 'utility:arrowup';
            first = 1;
            second = -1;
        } else if (iconName == 'utility:arrowup') {
            sortIcons[cname] = 'utility:arrowdown';
            first = -1;
            second = 1;
        }
        component.set("v.sortIcons", sortIcons);

Suggestions?

2
  • You just need to specify the src attribute on the icon. If you can do that, all that's left is to change the value from what it is here to a URL.
    – sfdcfox
    Mar 9, 2020 at 21:03
  • It's a lightning primitive and it instantiates an svg - so I'm thinking the whole reference needs to be replaced, it's just a matter of how. Mar 10, 2020 at 13:15

0

You must log in to answer this question.