Ordering format options to put certain languages first

Posted by: richard on 30 January 2025, 1:39 pm EST

    • Post Options:
    • Link

    Posted 30 January 2025, 1:39 pm EST - Updated 30 January 2025, 1:44 pm EST

    It seems like newly added formats/ cultures are added to the bottom of all lists. I would like to be able to order formats based on likelihood of use. And in the future order it by specific locale of a given user.

    For example, I’ve added pound and euro to the culture, and they show up in the dropdown, but I would like Euro and pound to be at the top rather than the bottom.

  • Posted 31 January 2025, 5:31 am EST - Updated 31 January 2025, 5:36 am EST

    Hi,

    You can override the internal API getCultureInfoDict method to rearrange the cultures displayed in the dropdown list. Below is a sample code snippet to achieve this:

    
    // Override the getCultureInfoDict method  
    var oldFn = GC.Spread.Common.CultureManager.getCultureInfoDict;  
    GC.Spread.Common.CultureManager.getCultureInfoDict = function () {  
      var cultureDic = oldFn.apply(this, arguments);  
      var orderedCultureDic = {};  
    
      // 1. Add prioritized cultures first  
      if (cultureDic['en-gb']) {  
        orderedCultureDic['en-gb'] = cultureDic['en-gb'];  
      }  
      if (cultureDic['fr-fr']) {  
        orderedCultureDic['fr-fr'] = cultureDic['fr-fr'];  
      }  
    
      // 2. Add remaining cultures in the original order  
      for (var key in cultureDic) {  
        if (key !== 'en-gb' && key !== 'fr-fr') {  
          orderedCultureDic[key] = cultureDic[key];  
        }  
      }  
    
      return orderedCultureDic;  
    };  
    

    Please note:

    1. Even after modifying the order, SpreadJS prioritizes its current culture setting. Ensure you update the default culture accordingly:
    GC.Spread.Common.CultureManager.culture('en-gb');  
    1. The “None” option will always appear first in the dropdown as this is part of the design and cannot be changed.

    In the example attached , the “en-gb” culture is prioritized and appears at the top. SpreadJS Designer will apply the culture settings based on the current SpreadJS culture.

    Feel free to reach out if you encounter any issues.

    Regards,

    Ankit

    Sample: CultureCustomizations.zip

  • Posted 31 January 2025, 2:30 pm EST

    Thanks Ankit! This is a really thorough answer

Need extra support?

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

Learn More

Forum Channels