Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member542603
Participant
Hello Fellas,

One of the most required features in a checkbox is to select All and deselect All. Since the feature is not available in SAC, here is a workaround to implement the feature.

Step 1:

Create a Checkbox_Group1 with one value "All"



Create Checkbox_Group2 which will have the list of all items.

Step 2:

On Initialization, retrieve the list, add the members to checkbox and select all by default.
var list=Table_1.getDataSource().getMembers("State",5000); //List of members to be added to the checkbox
var j=0;
for(var i=0;i<list.length;i++)
{
if(list[i].id.length!==0) //To remove null values
{
Actual_list[j]=list[i].description;
j++;
}
}
for(i=0;i<Actual_list.length;i++) // Add items to Checkbox
{
CheckboxGroup_2.addItem(Actual_list[i],Actual_list[i]);
}
CheckboxGroup_2.setSelectedKeys(Actual_list); //Select all as default
Selected_list=Actual_list;
//Selected_list - Current selected list to apply filter etc
//Actual_list - Standard list to compare the selection

The below is how the checkbox will look during run time.



Step 3:

On Checkbox_Group1 onSelect check if All is checked or Unchecked and make changes in Checkbox_Group2 selection.
var selection=this.getSelectedTexts();
if(selection[0]==="All")
{
Selected_list=Actual_list;
//Add Filter script
}
else
{
Selected_list=[""];
//Add Filter script
}
CheckboxGroup_2.setSelectedKeys(Selected_list);

Step 4:

On Checkbox_Group2 on Select check the number of entries selected and compare with count of actual list, based on which change the Checkbox_Group1 selection.
var selection=this.getSelectedTexts();
if(selection.length===Actual_list.length)
{
CheckboxGroup_1.setSelectedKeys(["All"]);
//Add Filter script
}
else
{
CheckboxGroup_1.setSelectedKeys([""]);
//Add Filter script
}

Aaaand Voila!!

Now you can use select the "All" entry to Select All or Deselect All.

Using Buttons:

Alternatively you can add two Buttons to Do the actions, which uses much simpler scripting.

The application will look like below in run time.


//Select All
CheckboxGroup_2.setSelectedKeys(Selected_list);
//Add Filter script

//De-Select All
CheckboxGroup_2.setSelectedKeys([]);
//Add Filter script

The above variants can be used with an input field to create similar to Dimension Filter in SAP Lumira... But that's for another time... Thank you guys for your time meet Y'all in the next post..

 

-Sathya
6 Comments
Labels in this area