cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Arranging the checkbox list posted using array from table

gfsampayan28
Explorer
0 Likes
1,757

Hi everyone, Does anyone know how to arrange this list on my checkbox posted using array from table? to another checkbox? If anyone could help or give some reference. Thankyou.

Note: Its better if the arrangement is based on the numbering on the another column. Please see attached image of table.

Accepted Solutions (0)

Answers (2)

Answers (2)

JBARLOW
Active Contributor
0 Likes

My understanding is that we want to add dimension member values to the checkboxGroup,
When added to the checkbox the values need to be sorted by the Rank column value.

Using the BestRunJuice sample data

We have a table with a dimension: Store & measure: Gross Margin
In your example Gross Margin would be the Rank column

When the button is clicked the store values will be added to the CheckBoxGroup,
They will be added in the order low > high based on the Gross Margin column.

The code in the button is:

CheckboxGroup_1.removeAllItems();
var dims = Table_1.getDimensionsOnRows()[0];

// sort the table low - high by the measures
var sel=Table_1.getDataSource().getDataSelections()[0];
Table_1.sortByValue(sel,SortOrder.Ascending,Direction.Vertical);

// the rest of the code grabs the values from the table and adds them to the checkbox

var selections=Table_1.getDataSource().getDataSelections();
var memberID = ArrayUtils.create(Type.string);
var memberDESC = ArrayUtils.create(Type.string);


for (var i = 0; i < selections.length; i++) {var member = Table_1.getDataSource().getResultMember(dims, selections[i]);
{  memberID.push(member.id);
   memberDESC.push(member.description);}}

for (var q=0;q<memberDESC.length;q++)	
		{CheckboxGroup_1.addItem(memberID[q],memberDESC[q]);}	

//remove the sort on the table
Table_1.removeSorting();
	

The table is sorted by Gross margin, the Store values are added to the Checkbox

At the end of the script we reset the table sort back to default

gfsampayan28
Explorer
0 Likes

Sir jbarlowjb on your sample code the checkbox list are sorted or arrange base on the gross of each item. Its works correctly. But I have a question. Is it also possible to arrange the checkbox list based also on the rank but it is cascaded from the specific type. Example: There are different type of juice. There is column on the table with sweet, sour, bitter taste of juice then another column for the specific juices under that kind of taste then another column for the rank of those juices. I'm looking for the way to sort the list of specific juices under for example the sweet taste of juice. Please see the sample image of table labeled by process.

JBARLOW
Active Contributor
0 Likes

You'll need to get the radio button to filter the table, to the taste of Juice --- then you can apply the logic I suggested above.

gfsampayan28
Explorer
0 Likes

Hi Sir jbarlowjb the thing is it is not filtered on table just logically filtered on checkbox and then arrange it before displaying. Just need to cascade the table logically then display the information sorted in the checkbox. So far, some reference I got do it in two for loop but I dont get how to simulate it properly. Any idea Sir ?

0 Likes

If you want to arrange the checkbox values according to the other dimension member, then one thing you can do. You can make the "Rank_Countries" the ID and "City Branch" as the description. And then you can just use a for loop to add the "City Branch" values to the Check Box which will be sorted according to the ID.

Please upvote, if this answer helps you.

gfsampayan28
Explorer
0 Likes

Question Sir argha2000 how can I do that if the list on the checkbox is cascaded from the list in the radio button? I just need to arrange the list according to the of rank_countries in the table?

gfsampayan28
Explorer
0 Likes

CheckboxGroup_1.removeAllItems();

res = Tbl_Retail_1.getDataSource().getResultSet({"Hemisphere_Globe":Checkbox_HemisphereList_arry});

console.log(res);

for (a=0; a<res.length; a++){

CheckboxGroup_1.addItem(res[a]["Rank_Branch"].id,res[a]["City_Branch"].description);

num

}

Note: After doing this one I still cant arrange the order of the displayed branch on the checkbox.