I have an Interactive Grid that has a select list and a radio group added in its toolbar using the following JavaScript code as the JavaScript initialization Code under the Region's Attributes > Advanced section in the APEX App Builder.
I have two page Items that are meant to persist the values from these controls during a session. P400_SH_FILTER_MIT_ID
holds the radio group's value and P400_SH_STATUS_FILTER
holds the select list's value. When the region is refreshed or the page is reloaded, I want the radio group and select list to have the respective values from those page items (as the default value basically), so the user does not have to make their selection in those controls again.
I tried to do this using the values attribute when adding the controls to the toolbar like so: value: $v("P400_SH_STATUS_FILTER")
however, this does not seem to do the trick. The page items have the correct values but the toolbar select list and radio group does not reflect that value.
Is there a comprehensive documentation on what attributes those controls can receive? is “value” simply the wrong attribute to specify such a default value? Or can anyone point me to another reason why this does not work as I expected?
I'm currently using Apex Version 23.2.3. Here is my JavaScript Initialization Code:
function(config) {
let $ = apex.jQuery,
toolbarData = $.apex.interactiveGrid.copyDefaultToolbar(), // copy the whole toolbar
toolbarGroup = toolbarData.toolbarFind("actions3");
// my status select list & its label
toolbarGroup.controls.push({
type: "STATIC",
label: "Status",
id: "status-select-label",
});
toolbarGroup.controls.push({
type: "SELECT",
id: "sh-status-select",
action: "select-status",
value: $v("P400_SH_STATUS_FILTER")
});
// my filter radio group
toolbarGroup.controls.push({
type: "RADIO_GROUP",
action: "set-sh-filter-mit-id",
id: "sh-filter-mit-id-switch",
value: $v("P400_SH_FILTER_MIT_ID")
});
// the select list's action
config.initActions = function (actions){
actions.add({
name: "select-status",
choices: [ {label: "Entered", value: "ENTERED"},
{label: "Processed", value: "PROC"},
{label: "Error", value: "ERROR"}],
action: function(event, focusElement){
let selectedValue = focusElement.options[focusElement.selectedIndex].value;
apex.item("P400_SH_STATUS_FILTER").setValue(selectedValue);
apex.region("SH_IG").refresh();
}
});
// the radio group's action
actions.add({
name: "set-sh-filter-mit-id",
choices: [
{ label: "Show All", value: "null" , title: "Show All" }
, { label: "Show My Own", value: +$v("P0_G_USER_ID"), title: "Show My Own" }
],
action: function (evt, elm) {
if (elm.value === "null" ) {
apex.item("P400_SH_FILTER_MIT_ID").setValue()
}
else {
apex.item("P400_SH_FILTER_MIT_ID").setValue(elm.value)
}
console.log("P400_SH_FILTER_MIT_ID="+apex.item("P400_SH_FILTER_MIT_ID").getValue())
apex.region("SH_IG").refresh()
}
});
};
config.toolbarData = toolbarData;
return config;
}