Creating Dynamic Tabs in VBCS
To do this we will create a Checkbox Set and map the same to Oracle Jet Tabs, when a specific checkbox is checked the tab mapped to it will be shown
- Create a New App
- Add a checkbox set to the page
- Add 2 more options and rename them accordingly
- Create 3 default Tabs and add some custom content inside each tab
- Inside oj-tab-bar make sure all li elements have an id value and the same is mapped to Tab regions switcher elements div slot
- Now test the Page to see all Tabs are working fine
- Now we have to write logic to map the checkbox to the Tabs for this create a custom Type with attributes id and name.
- Now create an ADP of the same type with id as key attribute
- Now create an on-Value event on Checkbox set and write logic to populate the ADP with id and Name value of the Tabs
PageModule.prototype.generateTabUsingCheckboxVal = function (checkboxValueArray) {
let generatedTabArray = [];
let generatedTabObj = {};
checkboxValueArray.forEach(element => {
console.log(element);
switch (element) {
case 'tab-1':
generatedTabObj = {};
generatedTabObj.id = 'oj-tab-1';
generatedTabObj.name = 'Tab 1';
generatedTabArray.push(generatedTabObj);
break;
case 'tab-2':
generatedTabObj = {};
generatedTabObj.id = 'oj-tab-2';
generatedTabObj.name = 'Tab 2';
generatedTabArray.push(generatedTabObj);
break;
case 'tab-3':
generatedTabObj = {};
generatedTabObj.id = 'oj-tab-3';
generatedTabObj.name = 'Tab 3';
generatedTabArray.push(generatedTabObj);
break;
default:
generatedTabObj = {};
generatedTabObj.id = 'oj-tab-1';
generatedTabObj.name = 'Tab 1';
generatedTabArray.push(generatedTabObj);
break;
}
});
return generatedTabArray;
};
- Now modify the oj-tab-bar as shown below to generate Tabs from ADP
<oj-tab-bar edge="top" id="oj-tab-bar-1653256789-1" selection="{{$variables.ojTabBar16532567891SelectedItem}}"
class="oj-flex-item oj-sm-12 oj-md-12" data="[[ $variables.DynamicTabADP ]]">
<template slot="itemTemplate" data-oj-as="item">
<li :id="[[item.data.id]]">
<a href="#">
<oj-bind-text value="[[item.data.name]]"> </oj-bind-text>
</a>
</li>
</template>
</oj-tab-bar>
- Now run the application and test the tabs
Comments
Post a Comment