
The "Set" operations feature is used to quickly change the field values/properties on the
page. An example would be to set all properties for a date field like Display As, Format Mask, Alignment, ...
Add a separator
If you look into one of the supplied example files, eg. apex_builder_plugin_4311.js you will see that the first call is
ApexBuilderPlugin.addSetOperation
( "General"
);
This call will generate a disabled separator entry in the "Set" select list. You can add your own separator entries,
just place them between your ApexBuilderPlugin.addSetOperation calls.
Simple Set operation
The next example is a real set operation call.
ApexBuilderPlugin.addSetOperation
( "Date Picker - date only"
, { "F4000_P4311_DISPLAY_AS": "PICK_DATE_DD_MON_YYYY"
, "F4000_P4311_CSIZE": "10"
, "F4000_P4311_CMAXLENGTH": "11"
}
);
- The first parameter is the description for the set operation and is displayed in the "Set" select list.
- The second parameter is an array of field id's and the value which should be set when the "Set" operation is selected by the user.
To get the IDs and the possible values of the fields on your Oracle APEX Builder page, I would recommend to use the "Inspect" feature of the "Firebug add-on. (Watch the video).
More complex Set operation
The addSetOperation also supports more complicated value assignments, not just fixed values. You can also write a
function which returns a value, instead of just specifying a fixed value. For example
ApexBuilderPlugin.addSetOperation
( "Money - right aligned"
, { "F4000_P4311_DISPLAY_AS": "TEXT"
, "F4000_P4311_CSIZE": "14"
, "F4000_P4311_CMAXLENGTH": "15"
, "F4000_P4311_TAG_ATTRIBUTES": function(pField)
{
return ApexBuilderPlugin.addText(pField.value, 'style="text-align:right;"');
}
, "P4311_FORMAT_MASK": "FML999G999G990D00"
}
);
In this example pField will contain the DOM element of F4000_P4311_TAG_ATTRIBUTES when the function is called.
You can use the ApexBuilderPlugin.addText function to make sure that the text you want to set isn't already contained
in the field.
Set operations for Tabular Form Bulk updates
The Plugin also supports Tabular Forms in an Oracle APEX Builder page. The syntax is the same, but for
Tabular Forms you have to specify the name of the field. eg. f03 or f05. Don't specify f03_0001!
ApexBuilderPlugin.addSetOperation
( "Center all Headings"
, { "f06": "CENTER"
}
);
If you use a function instead of a fixed value, then the function will have an additional parameter which contains the current row
which is processed. That gives you the possibility to read values from another field of the current row. The following example
will add a colon at the end of a label if there isn't one.
ApexBuilderPlugin.addSetOperation
( "Label add colon"
, { "f02": function(pField, pRow)
{
if (pField.value.search(/\:$/) == -1) return pField.value+":";
return pField.value;
}
}
);
Example for a checkbox
If the field which you want to set is a checkbox, then you have to set true or false as value.
ApexBuilderPlugin.addSetOperation
( "Uncheck sort"
, { "f09": false
}
);
That's it! Easy, isn't it? ;-)
Have fun and be more productive with the "Set" feature!