Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    String functions in Summary Builder (substring, replace, toUpperCase, etc.)

    Subject: String functions in Summary Builder (substring, replace, toUpperCase, etc.)


    Hi, Isomorphic!


    I’m using the Summary Builder and I’d like to know if there is any built-in support for string operations on the columns used there.

    Specifically, I’m looking for methods similar to the standard JavaScript/string APIs, such as:
    • substring()
    • replace()
    • replaceAll()
    • toUpperCase()
    • toLowerCase()
    • trim()
    • padStart()
    • padEnd()
    • repeat()
    • split()
    • length()
    For example, something like:

    Code:
    toUpperCase(fieldName)
    substring(fieldName, 0, 5)
    replace(fieldName, "old", "new")

    This is analogous to how numeric functions like max(), avg(), toPrecision(), round(), etc. are available in the Formula Builder.

    My questions are:
    1. Is there currently a way to use these kinds of string functions directly in the Summary Builder?
    2. If not, is there a recommended approach to extend the Summary/Formula Builder with custom string functions so they can be used from the UI?
    3. Any examples or docs you can point me to for registering custom functions (for either Summary Builder or Formula Builder) would be very helpful.

    Environment:
    • SmartGWT version: 13.1 pro

    Thanks in advance for any guidance!

    #2
    First question is: what are you trying to achieve?

    Most normal end users are unlikely to be effective with string manipulation functions. The only reason we offer a FormulaBuilder with math-related functions is because there are many end users who are proficient with using such functions because of spreadsheets.

    If you are trying to provide a way for a developer (not a normal end user) to do formatting, you should just use CellFormatter.

    If you have an unusual use case - very sophisticated end users who are trying to do advanced formatting that would normally require code - that's closer to the FormulaBuilder than the SummaryBuilder, since the FormulaBuilder does support custom MathFunctions:

    https://smartclient.com/smartclient-....mathFunctions

    However this would involve quite a bit of deep surgery to the FormulaBuilder (via the AutoChild system, presumably). This is an area where we would recommend Feature Sponsorship, to have something like a "StringFormulaBuilder" or "AdvancedSummaryBuilder" to the framework, which would allow the typical expected set of String manipulation functions, and where we would make it possible to enable it with a simple setting.

    Comment

    Working...
    X