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.
