LiveCode Lessons » How to - LiveCode Marketplace Products » How Do I Create a Formatting Pattern for a Column?

How Do I Create a Formatting Pattern for a Column?

This Lesson describes how to build a format pattern usable in the Data Grid Helper Plugin for formatting numbers.

What Are the Symbols supported by the Pattern?

You can build patterns by using:

spaces Separator replaced by the content of the DGH's thousands separator property.
# Digit placeholder. This code does not display extra zeros.
0 Digit placeholder. This code pads the value with zeros to fill the format.
. Decimal number replaced by the content of the DGH's decimal separator property.
$ - + / ( )
[color] Where color is any color name supported by the LiveCode syntax.

 

How Can I define Patterns for Positive, Negative or Zero Values?

A Pattern for a column can be separated in three patterns items:

- the first for Positive Numbers
- the second for Negative Numbers
- the last for Zero Values

Note that for having an empty result for Zero Values, you need to input a space in the last pattern item.

The pattern delimiter is the comma.

Could You Present Some Examples of What Can be Done With Patterns?

Could_you_present_some_examples_of_what_can_be_done_with_patt_display

How to format the numbers of this datagrid to have something more readable?

Here is some examples of usable patterns in DGH:

Positive Pattern: ########

Positive_pattern__________display

Positive Pattern: #######0

Positive_pattern________0_display

Positive Pattern: #######.##

Positive_pattern_________display

Positive Pattern: ######0.00

Positive_pattern_______0.00_display

Positive,Negative pattern: ######0.00,(######0.00)

Positive_negative_pattern_______0.00________0.00__display

Positive,Negative pattern: ######0.00,######0.00[red]

Positive_negative_pattern_______0.00_______0.00_red__display

Positive,Negative pattern: ### ##0.00[blue],-### ##0.00[red] (with thousands separator = , (comma))

Positive_negative_pattern_______0.00_blue__-______0.00_re_display

Positive,Negative,Zero value pattern: $### ##0.00,$### ##0.00[red],$0.00 (with thousands separator = , (comma))

Positive_negative_zero_value_pattern________0.00________0_display

$### ##0.00,$### ##0.00[red], (with thousands separator = , (comma))

_______0.00________0.00_red_____with_thousands_separato_1_display

Note the last pattern item contains a space.

Prev: How Do I Create a Menu Button in a Column? Next: How Do I Format a Number in a Column?

Comments (1)

Sunday Aug 21 at 10:14 PM William Moseid

Excellent!

Add your comment




E-Mail me when someone replies to this comment

Are you human?