Grid refresh not working on Load()

HI All, 

  please anyone help me with refreshing the grid data depending on the Dropdown selection, below is my code snippet,

load(
local!AllValuesMaster: rule!LMP_getAllValuesMasterFilters(
typeid: ri!typeValueSelected,
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: - 1,
sort: a!sortInfo(
field: "abbreviation",
ascending: true()
)
)
),
local!type: cast('type!{urn:com:appian:types:LMP}LMP_REF_TYPES?list',
rule!LMP_getTypesListByFilters(
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: - 1,
sort: a!sortInfo(
field: "abbreviation",
ascending: true()
)
)
)
),



a!formLayout(
label: "Administration",
contents: {

a!sectionLayout(
contents: {
a!dropdownField(
label: "Master Data",
labelPosition: "ABOVE",
placeholderLabel: "--- Select a Value ---",
choiceLabels: {
"Type",
local!type.description
},
choiceValues: {
0,
local!type.typeid
},
value: ri!typeValueSelected,
saveInto:ri!typeValueSelected ,

validations: {}
),
a!boxLayout(
label: if(or(isnull(ri!typeValueSelected),ri!typeValueSelected = 0),
"Type",
rule!LMP_getTypesListByFilters(
typeid: ri!typeValueSelected
).description),
showWhen: ri!showhen,
contents: {
a!gridLayout(
label: "",
headerCells: {
a!gridLayoutHeaderCell(
label: "TypeId"
),
a!gridLayoutHeaderCell(
label: "Abbreviation"
),
a!gridLayoutHeaderCell(
label: "Description"
),
a!gridLayoutHeaderCell(
label: "Active"
),
a!gridLayoutHeaderCell(
label: ""
),
a!gridLayoutHeaderCell(
label: ""
)

},
columnConfigs: {
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(),
a!gridLayoutColumnConfig(),
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(
width: "ICON"
)
},
rows: a!forEach(
items: local!AllValuesMaster,
expression: a!gridRowLayout(
contents: {
a!textField(
value: fv!item.typeid,
saveInto: fv!item.typeid
),
a!textField(
value: fv!item.abbreviation,
saveInto: fv!item.abbreviation
),
a!textField(
value: fv!item.description,
saveinto: fv!item.description
),
a!checkboxField(
label: "gbe-active",
choiceLabels: {
""
},
choiceValues: {
true()
},
value: if(
or(
isnull(
fv!item.activein
),
not(
fv!item.activein
)
),
null,
toboolean(
fv!item.activein
)
),
saveInto: {
a!save(
fv!item.activein,
if(
isnull(
save!value
),
false(),
save!value
)
)

},
align: "CENTER"
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"MOVE_UP"
),
altText: "Up",
caption: "Move Up ",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
fv!index = 1,
{},
{
a!save(
local!AllValuesMaster,
insert(
local!AllValuesMaster,
fv!item,
fv!index - 1
)
),
a!save(
local!AllValuesMaster,
remove(
local!AllValuesMaster,
fv!index + 1
)
)
}
)
}
)
),
size: "ICON"
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"MOVE_DOWN"
),
altText: "Down",
caption: "Move Down ",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
fv!index = count(
local!AllValuesMaster
),
{},
{
a!save(
local!AllValuesMaster,
insert(
local!AllValuesMaster,
fv!item,
fv!index + 2
)
),
a!save(
local!AllValuesMaster,
remove(
local!AllValuesMaster,
fv!index
)
)
}
)
}
)
),
size: "ICON"
)
}
)
),
addRowLink: a!dynamicLink(
label: "Add " & if(or(isnull(ri!typeValueSelected),ri!typeValueSelected = 0),
"Type",
rule!LMP_getTypesListByFilters(
typeid: ri!typeValueSelected
).description),
saveInto: a!save(
local!type,
append(
local!type,
'type!{urn:com:appian:types:LMP}LMP_REF_TYPES'(
activein: true()
)
)
)
),
shadeAlternateRows: true,
paginginfo: a!pagingInfo(
startIndex: 1,
batchSize: -1,
sort: a!sortInfo(
field: "abbreviation",
ascending: true()
)
)
)

}



),


}
)

},
buttons: a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Submit",
submit: true,
style: "PRIMARY"
)
},
secondaryButtons: {
a!buttonWidget(
label: "Cancel",
value: true,
saveInto: ri!cancel,
submit: true,
style: "NORMAL",
validate: false
)
}
)

)
)

Thanks in advance

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    I'll look thru your code in a second, but as a piece of advice (and personal request), when you post long (or any) snippets of code like this, it's far better if you use the "Insert --> Insert Code" functionality provided by the Community software, which generates a code box which you can then paste your code into.  This preserves formatting and indentation (thus making the code readable), and prevents the code from making the post multiple pages long (thus making the post readable).

    Anyway -- reading thru your code a bit - your grid data is initially loaded into a load() variable, which is fine if you're below 19.2 (otherwise you should be using a!localVariables() only) -- but your dropdown to choose the type ID is just saving a value to the local type ID variable and not re-querying the grid data.  A load variable will not update automatically when a filter value changes (for example), by design - any changes have to be "pushed" in from external components and using a!save().

    I also caution you here - since you're apparently adding rows and editing values in this grid, you should probably NOT be allowing the user to filter the rows down using a dropdown, as this would erase changes that have been made on-form but not yet saved to the database.  If you want to allow live filtering like this, you should be using a read-only grid instead.

Reply
  • 0
    Certified Lead Developer

    I'll look thru your code in a second, but as a piece of advice (and personal request), when you post long (or any) snippets of code like this, it's far better if you use the "Insert --> Insert Code" functionality provided by the Community software, which generates a code box which you can then paste your code into.  This preserves formatting and indentation (thus making the code readable), and prevents the code from making the post multiple pages long (thus making the post readable).

    Anyway -- reading thru your code a bit - your grid data is initially loaded into a load() variable, which is fine if you're below 19.2 (otherwise you should be using a!localVariables() only) -- but your dropdown to choose the type ID is just saving a value to the local type ID variable and not re-querying the grid data.  A load variable will not update automatically when a filter value changes (for example), by design - any changes have to be "pushed" in from external components and using a!save().

    I also caution you here - since you're apparently adding rows and editing values in this grid, you should probably NOT be allowing the user to filter the rows down using a dropdown, as this would erase changes that have been made on-form but not yet saved to the database.  If you want to allow live filtering like this, you should be using a read-only grid instead.

Children