Editable Grid - Dynamic columns

Have anyone implemented "dynamic columns in editable grid"? Say for example my matrix rows and column vary per product or category

1. Category - 10 * 11 columns
2. Category - 10 * 3 columns etc. Rather than creating multiple SAIL rules, planning to use one SAIL rule for interface and one SAIL for grid layout.

OriginalPostID-251485



  Discussion posts and replies are publicly visible

  • You can make the grid dynamic by using apply for both the headerCells and GridRowlayout, calling a generic rule to generate the headercells, and a generic rule to generate the grid rows. It's not that difficult if you can understand how the apply function works. One thing that should know is that you should apply on an enumeration of the indices of the rows/columns and pass the entire dataset into the generic rules.
  • Example:

    a!gridLayout
    (
              headerCells:
              fn!apply
              (
                        rule!genericRuleGeneratesHeaderCell
                        (
                                  ri!columns,
                                  _
                        ),
                        fn!enumerate(fn!count(ri!columns))
              ),
              rows:
              fn!apply
              (
                        rule!genericRuleGeneratesGridRow
                        (
                                  ri!data,
                                  _
                        ),
                        fn!enumerate(fn!count(ri!data))
              )
    )
  • Marky, I've already used apply for header cells, rows and column configs, what you see is taken from my sample rule, but the real issue is saving values from dynamic drop down column control..
  • rule: genericRuleGeneratesGridRow

    inputs:

    data | any type
    index | number(integer)

    definition:

    a!gridRowLayout
    (
              contents:
              {
                        a!dropdownField
                        (
                                  label:"Sample Dropdown",
                                  value:ri!data[ri!index].integerField,
                                  saveInto: ri!data[ri!index].integerField,
                                  placeholderLabel:"-- Select --",
                                  choiceLabels:{1,2,3},
                                  choiceValues:{1,2,3}
                        )
              }
    )
  • This will work only if one drop down column and save values in gridRowLayout..

    here is the sample which is not working.. changing one dropdown chaning all row dropdown.. Any suggestion..
    a!applyComponents(
    function: a!dropdownField(
    label: _,
    choiceLabels: {1,2,3},
    placeholderLabel: "--Select-- ",
    choiceValues: {1,2,3},
    value: ri!items[ri!index].response,
    saveInto: ri!items[ri!index].response,
    disabled: false()
    ),
    arrayVariable : local!columnIndex,
    array: 1+enumerate(count(ri!inputColumns)))
    )
  • Resolve issue by using creating sub rule for drop down control and passing input value for response as array rather single value.. Thanks for your response Marky
  • Can you explain more about this rule? whats its function?
    rule!genericRuleGeneratesHeaderCell
    (
    ri!columns,
    _
    )