Skip to content

Feature: number / date format for text-template parameters (ContentParams / CaptionParams) — decimal precision, group digits, date format #1219

Description

@MohamedElNady

Use case

Dynamic texts and captions with a Decimal parameter render with the attribute's default formatting. For example, Content: '{1} / 100', ContentParams: [{1} = HealthScore] shows "20.00 / 100" where the design needs "20 / 100". In Studio Pro, each template parameter has formatting options: decimal precision, group digits, and date format for DateTime. These are stored in the parameter's FormattingInfo, for example DecimalPrecision.

MDL has no way to set them. mxcli syntax --json (v0.24.0) contains no DecimalPrecision, GroupDigits or FormattingInfo. So every number or date shown through a template needs a Studio Pro edit or an extra formatted-string attribute. Re-running the page script then silently brings back the default format.

Proposed syntax (one option)

dynamictext txtScore (Content: '{1} / 100',
  ContentParams: [{1} = HealthScore (DecimalPrecision: 0, GroupDigits: false)])

dynamictext txtDue (Content: 'Due {1}',
  ContentParams: [{1} = DueDate (DateFormat: Date)])   -- Date | Time | DateTime | Custom 'dd MMM yyyy'

describe page would emit the same, so the round-trip keeps it.

Mendix version

Tested against 11.14.0. The formatting options exist on text-template parameters in 10.x and 11.x.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions