Modify Conditional Formatting Icons

Posted by: adisa.craig on 16 October 2019, 12:54 am EST

  • Posted 16 October 2019, 12:54 am EST

    Is there a way to modify the icons that are used for Conditional Formatting with the Icon Sets Rule? For example changing the image used for the grey arrow to a different one?
  • Marked as Answer

    Replied 16 October 2019, 6:08 pm EST

    Hi Adisa,

    You could define custom icons by overriding the getIcon() method of IconSetRule class. Please refer to the following code snippet and the sample demonstrating the same:
    // override to use custom icons
    var base = GC.Spread.Sheets.ConditionalFormatting.IconSetRule.getIcon;
    GC.Spread.Sheets.ConditionalFormatting.IconSetRule.getIcon = function(
    iconSetType,
    iconIndex
    ) {
    var icon = base.apply(this, arguments);
    if (
    iconSetType ===
    GC.Spread.Sheets.ConditionalFormatting.IconSetType.fiveArrowsColored
    ) {
    let custom = getIconURL(iconIndex);
    if (custom) {
    icon.image = custom;
    icon.w = 16;
    icon.h = 16;
    icon.x = 0;
    icon.y = 0;
    }
    }
    return icon;
    };

    https://codesandbox.io/s/spread-js-starter-0pcoz

    Regards
    Sharad
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels