Editable Grid Component

Editable Grid

SAIL Function: a!gridLayout()

Arranges SAIL components in a tabular layout to provide quick inline editing of fields.

See also: Paging Grid

Parameters

Name Keyword Type Description
Label label Text Optional text to display as the grid layout's label.
Label Position labelPosition Text Optional text to determine where the label appears. Valid values include
  • "ABOVE" (default) Displays the label above the component.
  • "ADJACENT" Displays the label to the left of the component.
  • "COLLAPSED" Hides the label. The label will still be read by screen readers; see accessibility considerations for more information.
Instructions instructions Text Optional text displayed below the field's label.
Help Tooltip helpTooltip Text Displays a help icon with the specified text as a tooltip. The tooltip displays a maximum of 500 characters. The help icon does not show when the label position is "COLLAPSED".
Total Count totalCount Integer Total number of rows of data in the grid.
Empty Grid Message emptyGridMessage Text Text to display in the grid when no data is available. Default is "No items available".
Header Cells headerCells Header Cell Array Each grid layout header cell corresponds to a column header. Configured using a!gridLayoutHeaderCell(label, align, helpTooltip).
Column Configurations columnConfigs Column Configurations Array Each column configuration corresponds to a column. Configured using a!gridLayoutColumnConfig(width)
Rows rows Row Array Rows that are displayed in the grid. Configured using a!gridRowLayout(contents, id, selectionDisabled).
Selectable selectable Boolean Determines if the selection column is displayed. Default is false.
Selection Required selectionRequired Boolean Determines if at least one row must be selected. Default is false.
Selection Disabled selectionDisabled Boolean Determines if selection is disabled in all rows. Default is false.
Selected Rows selectionValue Any Type Array The ids of the rows that are selected.
Save Selection To selectionSaveInto Save Array One or more variables that are updated with the selected identifiers when the user changes selections. Use a!save(target, value) to save a modified or alternative value to a variable.
Add Row Link addRowLink Dynamic Link Link for adding a row to the grid. Create link using a!dynamicLink().
Validations validations Text or Validation Message Array Validation errors to be displayed below the field. Configured using a text array or an array with a mix of text and Validation Message using a!validationMessage(message, validateAfter).
Validation Group validationGroup Text When present, this field is only validated when a button in the same validation group is clicked.
Visibility showWhen Boolean Determines whether the component is displayed on the interface. When set to false, the component is hidden and is not evaluated. Default: true.

Notes

  • Performance is affected by the number of components in an interface. If your interface contains an editable with many cells, the interface may feel slow. See also: SAIL Performance
  • When a SAIL component is placed into a grid cell, the following component configurations are ignored: label, instructions, label position. Validation messages on the SAIL component within the grid cell are displayed when the component's value is not null.
  • Components configured with required set to true do not display the red asterisk; when submitting or selecting a validating button, the required validation message is displayed when the component's value is null.
  • Every row in the grid must have the same number of cells. The number of cells in each row must also match the number of header cells.
  • The components placed within a grid cell can be different across the rows in one column.
  • When selection is enabled, the checkbox in the header selects all rows that are not disabled.
  • The Grid Text Column and Grid Image Column components cannot be used in an editable grid.
  • When placing an Image Field component inside an editable grid, there are some additional restrictions that do not apply when an image component is outside of a grid.
  • The image component behaves slightly differently when it is placed inside of a Grid Layout component than when it is outside of a Grid Layout.
    • Inside an editable grid, the only valid sizes are THUMNBNAIL and ICON. The size STANDARD is not allowed.
    • Inside an editable grid, the default size for an image component is THUMBNAIL
    • Inside an editable grid, you can only have 0 or 1 images in an image component. Multiple images in the same grid cell are not supported.
    • When inside an editable grid column with Size of NARROW or ICON, the size of the image component must be ICON.
    • All image components in the same column must have the same size.

Examples

Copy and paste an example to the Interface Designer to see it displayed.

Editable Grid with 2 Rows

=load(
  local!items: {
    {item: "Item 1", qty: 1, unitPrice: 10},
    {item: "Item 2", qty: 2, unitPrice: 20}
  },
  a!gridLayout(
    label: "Grid Layout",
    instructions: "This is a grid layout",
    headerCells: {
      a!gridLayoutHeaderCell(label: "Item"),
      a!gridLayoutHeaderCell(label: "Qty", align: "RIGHT"),
      a!gridLayoutHeaderCell(label: "Unit Price", align: "RIGHT"),
      a!gridLayoutHeaderCell(label: "Total", align: "RIGHT")
    },
    rows: {
      a!gridRowLayout(
        contents: {
            a!textField(
            value: local!items[1].item,
            saveInto: local!items[1].item
          ),
          a!integerField(
            value: local!items[1].qty,
            saveInto: local!items[1].qty,
            align: "RIGHT"
          ),
          a!floatingPointField(
            value: local!items[1].unitPrice,
            saveInto: local!items[1].unitPrice,
            align: "RIGHT"
          ),
          a!textField(
            value: dollar(tointeger(local!items[1].qty) * todecimal(local!items[1].unitPrice)),
            readOnly: true,
            align: "RIGHT"
          )
        }
      ),
      a!gridRowLayout(
        contents: {
          a!textField(
            value: local!items[2].item,
            saveInto: local!items[2].item
          ),
          a!integerField(
            value: local!items[2].qty,
            saveInto: local!items[2].qty,
            align: "RIGHT"
          ),
          a!floatingPointField(
            value: local!items[2].unitPrice,
            saveInto: local!items[2].unitPrice,
            align: "RIGHT"
          ),
          a!textField(
            value: dollar(tointeger(local!items[2].qty) * todecimal(local!items[2].unitPrice)),
            readOnly: true,
            align: "RIGHT"
          )
        }
      )
    }
  )
)

Editable Grid with Validations

=load(
  local!items: {
    {item: "Item 1", qty: 10, unitPrice: 10},
    {item: "Item 2", qty: 2,  unitPrice: 20}
  },
  a!gridLayout(
    label: "Grid Layout",
    instructions: "This is a grid layout",
    headerCells: {
      a!gridLayoutHeaderCell(label: "Item"),
      a!gridLayoutHeaderCell(label: "Qty", align: "RIGHT"),
      a!gridLayoutHeaderCell(label: "Unit Price", align: "RIGHT"),
      a!gridLayoutHeaderCell(label: "Total", align: "RIGHT")
    },
    rows: {
      a!gridRowLayout(
        contents: {
            a!textField(
            value: local!items[1].item,
            saveInto: local!items[1].item
          ),
          a!integerField(
            value: local!items[1].qty,
            saveInto: local!items[1].qty,
            align: "RIGHT"
          ),
          a!floatingPointField(
            value: local!items[1].unitPrice,
            saveInto: local!items[1].unitPrice,
            align: "RIGHT"
          ),
          a!textField(
            value: dollar(tointeger(local!items[1].qty) * todecimal(local!items[1].unitPrice)),
            readOnly: true,
            align: "RIGHT"
          )
        }
      ),
      a!gridRowLayout(
        contents: {
          a!textField(
            value: local!items[2].item,
            saveInto: local!items[2].item
          ),
          a!integerField(
            value: local!items[2].qty,
            saveInto: local!items[2].qty,
            align: "RIGHT"
          ),
          a!floatingPointField(
            value: local!items[2].unitPrice,
            saveInto: local!items[2].unitPrice,
            align: "RIGHT"
          ),
          a!textField(
            value: dollar(tointeger(local!items[2].qty) * todecimal(local!items[2].unitPrice)),
            readOnly: true,
            align: "RIGHT"
          )
        }
      )
    },
    validations: {
      if(
        sum(tointeger(local!items.qty) * todecimal(local!items.unitPrice))>100,
        "Total must not exceed $100",
        null
      ),
      if(
        length(local!items)<3,
        a!validationMessage(
          message: "Enter at least 3 items",
          validateAfter: "SUBMIT"
        ),
        null
      )
    }
  )
)

Editable Grid with Selection

=load(
  local!items: {
    {item: "Item 1", qty: 1, unitPrice: 10},
    {item: "Item 2", qty: 2, unitPrice: 20}
  },
  local!selected: tointeger({}),
  a!gridLayout(
    label: "Grid Layout",
    instructions: "Selected: " & local!selected,
    headerCells: {
      a!gridLayoutHeaderCell(label: "Item"),
      a!gridLayoutHeaderCell(label: "Qty", align: "RIGHT"),
      a!gridLayoutHeaderCell(label: "Unit Price", align: "RIGHT"),
      a!gridLayoutHeaderCell(label: "Total", align: "RIGHT")
    },
    rows: {
      a!gridRowLayout(
        id: 1,
        contents: {
            a!textField(
            value: local!items[1].item,
            saveInto: local!items[1].item
          ),
          a!integerField(
            value: local!items[1].qty,
            saveInto: local!items[1].qty,
            align: "RIGHT"
          ),
          a!floatingPointField(
            value: local!items[1].unitPrice,
            saveInto: local!items[1].unitPrice,
            align: "RIGHT"
          ),
          a!textField(
            value: dollar(tointeger(local!items[1].qty) * todecimal(local!items[1].unitPrice)),
            readOnly: true,
            align: "RIGHT"
          )
        }
      ),
      a!gridRowLayout(
        id: 2,
        contents: {
          a!textField(
            value: local!items[2].item,
            saveInto: local!items[2].item
          ),
          a!integerField(
            value: local!items[2].qty,
            saveInto: local!items[2].qty,
            align: "RIGHT"
          ),
          a!floatingPointField(
            value: local!items[2].unitPrice,
            saveInto: local!items[2].unitPrice,
            align: "RIGHT"
          ),
          a!textField(
            value: dollar(tointeger(local!items[2].qty) * todecimal(local!items[2].unitPrice)),
            readOnly: true,
            align: "RIGHT"
          )
        }
      )
    },
    selectable: true,
    selectionValue: local!selected,
    selectionSaveInto: local!selected
  )
)

Editable Grid with Weighted Columns

=load(
  local!items: {
    {item: "Item 1", qty: 10, unitPrice: 10},
    {item: "Item 2", qty: 2,  unitPrice: 20}
  },
  a!gridLayout(
    label: "Grid Layout",
    instructions: "This is a grid layout with narrow columns",
    headerCells: {
      a!gridLayoutHeaderCell(label: "Item"),
      a!gridLayoutHeaderCell(label: "Qty", align: "RIGHT"),
      a!gridLayoutHeaderCell(label: "Unit Price", align: "RIGHT"),
      a!gridLayoutHeaderCell(label: "Total", align: "RIGHT")
    },
    columnConfigs: {
      a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 5),
      a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
      a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
      a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2)
    },
    rows: {
      a!gridRowLayout(
        id: 1,
        contents: {
            a!textField(
            value: local!items[1].item,
            saveInto: local!items[1].item
          ),
          a!integerField(
            value: local!items[1].qty,
            saveInto: local!items[1].qty,
            align: "RIGHT"
          ),
          a!floatingPointField(
            value: local!items[1].unitPrice,
            saveInto: local!items[1].unitPrice,
            align: "RIGHT"
          ),
          a!textField(
            value: dollar(tointeger(local!items[1].qty) * todecimal(local!items[1].unitPrice)),
            readOnly: true,
            align: "RIGHT"
          )
        }
      ),
      a!gridRowLayout(
        id: 2,
        contents: {
          a!textField(
            value: local!items[2].item,
            saveInto: local!items[2].item
          ),
          a!integerField(
            value: local!items[2].qty,
            saveInto: local!items[2].qty,
            align: "RIGHT"
          ),
          a!floatingPointField(
            value: local!items[2].unitPrice,
            saveInto: local!items[2].unitPrice,
            align: "RIGHT"
          ),
          a!textField(
            value: dollar(tointeger(local!items[2].qty) * todecimal(local!items[2].unitPrice)),
            readOnly: true,
            align: "RIGHT"
          )
        }
      )
    }
  )
)
FEEDBACK