Multiple dropdown filter for editable grid

Hello,

I have recently created a grid with data pulling from a CDT. I created a separate account filters interface for multiple dropdowns to be used to filter the data within the grid. Below I will share code snippets of the multiple dropdown filters interface, the query expression rule, the save rule, and the grid/filter put together in that order.

FILTER INTERFACE:

a!localVariables(
  local!aggregateCptyAccounts:
  rule!TS_QE_aggregateCptyAccountCodes(),
  local!aggregateCptyAccountNames:
  rule!TS_QE_aggregateCptyAccountNames(),
  local!aggregateCptyAccountTypes:
  rule!TS_QE_aggregateCptyAccountTypes(),

  a!cardLayout(
    contents: {
      a!sectionLayout(
        label: "Account Filters",
        contents: {
{
  a!multipleDropdownField(
    label: "Cpty Account Codes",
    labelPosition: "ABOVE", placeholder: "account codes",
    choiceLabels: {local!aggregateCptyAccounts},
    choiceValues: {local!aggregateCptyAccounts},
    value: ri!cptyAccountCode,
    saveInto: {ri!cptyAccountCode, rule!TS_RULE_cptyAccountCodeSaveExpression()},
    searchDisplay: "AUTO",
    validations: {}
  ),
  a!multipleDropdownField(
    label: "Cpty Account Names",
    labelPosition: "ABOVE", placeholder: "account names",
    choiceLabels: {local!aggregateCptyAccountNames},
    choiceValues: {local!aggregateCptyAccountNames},
    value: ri!cptyAccountName,
    saveInto: {ri!cptyAccountName, rule!TS_RULE_cptyAccountCodeSaveExpression()},
    searchDisplay: "AUTO",
    validations: {}
  ),
  a!multipleDropdownField(
    label: "Cpty Account Types",
    labelPosition: "ABOVE", placeholder: "account types",
    choiceLabels: {local!aggregateCptyAccountTypes},
    choiceValues: {local!aggregateCptyAccountTypes},
    value: ri!cptyAccountType,
    saveInto: {ri!cptyAccountType, rule!TS_RULE_cptyAccountCodeSaveExpression()},
    searchDisplay: "AUTO",
    validations: {}
  )
          }
        },
        isCollapsible: true()
      )
    },
    shape: "SEMI_ROUNDED"
  )
)

QE RULE:

index(
  index(
    a!queryEntity(
      entity: cons!TS_DATA_2,
      query: a!query(
        aggregation: a!queryAggregation(
        aggregationColumns: {
          a!queryAggregationColumn(
            field: "cptyAccountCode",
            isGrouping: true
            )
          }
        ),
        pagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: 50
        )
      ),
      fetchTotalCount: false
     ),
    "data", null
  ),
  "cptyAccountCode", null
)

SAVE RULE:

{
  a!save(
    ri!accountGridFilters,
    {
      cptyAccountCode: null,
      cptyAccountName: null,
      cptyAccountType: null
    }
  )
}

GRID/FILTER TOGETHER:

{
  rule!TS_accountFilters(
    cptyAccountCode: ri!cptyAccountCode,
    cptyAccountName: ri!cptyAccountName,
    cptyAccountType: ri!cptyAccountType,
    accountGridFilters: ri!accountGridFilters
  ),
  
  a!gridLayout(
    label: "",
    labelPosition: "COLLAPSED",
    headerCells: {
      a!forEach(
        items: if(
          ri!showGrid <> true(),
          enumerate(count(ri!columnsList) + 3),
          enumerate(count(ri!columnsList) + 2)
        ),
        expression: a!gridLayoutHeaderCell(label: "")
      )
    },
    columnConfigs: {
      a!gridLayoutColumnConfig(width: "DISTRIBUTE")
    },
    rows: {
      a!gridRowLayout(
        id: 1,
        contents: {
          a!textField(
            showWhen: ri!showGrid <> true(),
            readOnly: true()
          ),
          a!textField(readOnly: true()),
          a!textField(readOnly: true()),
          a!forEach(
            items: ri!columnsList,
            expression: rule!TS_FLD_accountGridHeaderNameField(
              pagingInfo: ri!pagingInfo,
              field: fv!item,
              headerName: cons!TS_COLUMN_LIST_FOR_CPTY_ACCOUNTS[wherecontains(
                fv!item, cons!TS_FIELDS_LIST_FOR_CPTY_ACCOUNTS
              )],
              saveExpression: {
                a!save(
                  ri!accountDetails,
                  rule!TS_getAccountDetailsByAdvanceFilter(
                    cptyAccountCode: ri!cptyAccountCode,
                    cptyAccountName: ri!cptyAccountName,
                    cptyAccountType: ri!cptyAccountType
                  )
                )
              },
              isSelectAllAccounts: ri!isSelectAllAccounts,
              updateAccountIds: ri!updateAccountIds,
              nonUpdateAccountIds: ri!nonUpdateAccountIds
            )
          )
        },
        selectionDisabled: true()
      ),
      a!forEach(
        items: ri!cptyAccountDetails,
        expression: a!gridRowLayout(
          id: 2,
          contents: {
            a!richTextDisplayField(
              value: {
                a!richTextIcon(
                  icon: if(
                    ri!isSelectAllAccounts = false,
                    "square-o",
                    "check-square-o-alt"
                  ),
                  link: a!dynamicLink(
                    saveInto: {
                      a!save(
                        ri!isSelectAllAccounts,
                        if(
                          ri!isSelectAllAccounts = false,
                          true,
                          false
                        )
                      ),
                      a!save(
                        {
                          ri!updateAccountIds,
                          ri!nonUpdateAccountIds
                        },
                        null
                      ),
                      if(
                        and(
                          a!isNotNullOrEmpty(ri!buttonAction),
                          ri!buttonAction = cons!TS_TXT_BULK_EDIT
                        ),
                        a!save(ri!buttonAction, null),
                        {}
                      )
                    }
                  ),
                  linkStyle: "STANDALONE",
                  size: "MEDIUM"
                )
              },
              showWhen: ri!showGrid <> true()
            ),
            a!textField(readOnly: true()),
            a!textField(readOnly: true()),
            a!textField( value: fv!item.id,readOnly: true()),
            a!textField( value: fv!item.cptyAccountCode,readOnly: true()),
            a!textField( value: fv!item.cptyAccountName,readOnly: true()),
            a!textField( value: fv!item.cptyCode,readOnly: true()),
            a!textField( value: fv!item.cptyAccountType,readOnly: true()),
            a!textField( value: fv!item.isActive,readOnly: true()),
            a!textField( value: fv!item.createdDt,readOnly: true()),
            a!textField( value: fv!item.createdBy,readOnly: true()),
            a!textField( value: fv!item.lastModifiedDt,readOnly: true()),
            a!textField( value: fv!item.lastModifiedBy,readOnly: true()),
            a!textField( value: fv!item.fundCode,readOnly: true()),
            a!textField( value: fv!item.accountNumber,readOnly: true())
            
          },
          selectionDisabled: true()
        )
      )
    },
    selectionSaveInto: {},
    selectionStyle: "ROW_HIGHLIGHT",
    validations: {},
    shadeAlternateRows: true,
    spacing: "DENSE"
  )
  
}

I believe I have most of the pieces together, I can click on multiple of the filters from the dropdown and it selects it and saves that selection. What am I missing in order to get the GRID to actually filter when I make a selection from the dropdown? Right now I can make a selection and it saves that selection but no filtering of the GRID, am I missing a queryFilter?

Thanks in advance.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Could you please provide more details about the data you are passing to the grid and where you are querying the data? Additionally, ensure that the selected account codes, names, and types are passed to the query rule as query filters.

  • The data being passed in to the grid is a Custom Data-Type setup as an entity within a data store and then set to a constant called TS_DATA_2 which you can see in the query expression rule. For the purpose of this, I only sent the account codes QE rule but I have the account names and account types QE rules setup the same way. 

  • 0
    Certified Lead Developer
    in reply to TomWould

    I recommend performing the following checks to resolve the issues:

    1. If you are using the query expression rule mentioned above to populate the grid data, ensure that you configure the query filters for each of the selected options.

    2. Run the query expression rule independently with various filter values (i.e., different account codes, account types, and account names) to verify if the query rule produces the desired output.

    3. Double-check that the correct rule input is utilized within the grid to populate the data and that the queried data is correctly passed through that rule input.