cancel
Showing results for 
Search instead for 
Did you mean: 

SAC APP Designer - How to display selected value in a text cell

JBARLOW
Contributor
0 Kudos
2,487

Just wondering if anyone has an idea on how to achieve the following:

Requirement:
When I click on the table I'd like the clicked value to be shown in the text box.
Could be either a dimension or measure - from any column/row in the table.

e.g. If I click the value 'Los Angeles' - that's what is shown in the text box
or I could click 0.09 in the Quantity sold column , so I'd want to see 0.09 in the text box.

I've got it partially working, just not fully dynamic (a user could click any cell in the table)

For the dimensions I can only get it working via hardcoding a dimension (so doesn't really deliver what I want)

var sel = tbl.getSelections()[0];
var result = tbl.getDataSource().getResultMember("Product_3e315003an",sel).description;
txt_box.applyText(result)

For measures this works

var sel = tbl.getSelections()[0];
var value = tbl.getDataSource().getData(sel).formattedValue;
txt_box.applyText(value);

So i need to find a way to wrap it all into one script that dynamically puts whatever value is clicked in the text box
and can dynamically tell which dimension has been clicked.

Accepted Solutions (1)

Accepted Solutions (1)

JBARLOW
Contributor
0 Kudos

Very late update 🙂

This code worked for me - very clunky and only good for a table containing 1 Dim and 1 Measure

var sel = T1.getSelections()[0];
var dim = T1.getDimensionsOnRows()[0];
var selM = sel[Alias.MeasureDimension];


if(selM===undefined)
	{
var result = T1.getDataSource().getResultMember(dim,sel).description;
txt_box.applyText(result);
	}

else{
var value2 = T1.getDataSource().getData(sel).formattedValue;
txt_box.applyText(value2);}

Answers (3)

Answers (3)

dominik_zed
Participant
0 Kudos

Hi everybody, Please vote for idea 280582: Improvement Request Details - Customer Influence (sap.com) ; This should solve the limitation "only good for a table containing 1 Dim"; Thanks

saurabh_sonawane
Active Contributor
0 Kudos

Hi ,

var sel = tbl.getSelections()[0];

If we use the above code then we will be getting both the dimension in it (product and location )

as per the current limitation, we can get only one dimension from the table

I would suggest the display both the dimension in the text box.

use the following code.

var sel = tbl.getSelections();

var result = "Selected product = " +sel[0]["product"] + "Selected Location =" + sel[0]["Location"]

txt_box.applyText(result)

Thanks,

Saurabh S.

JBARLOW
Contributor
0 Kudos

Thanks for comment,

Alas not really what I need.

The main requirement is to return whatever single value is selected in the table - could be a measure or dimension value.

I gave the text box as an example - as that was the easiest way to contextualise what i'm trying to do.
There are number of things I need to try and achieve that require getting the single value selected -- could be to pass it to part of a url, could be to display it as text , or to concatenate it etc etc etc.

Bob0001
Advisor
Advisor
0 Kudos

Hi jbarlowjb, you are using the right methods. However, the limitation comes from the getSelection method which will give you the full coordinates if you click on a header cell. You can think of it as if there is no cell spanning and all tuples of one row are treated as one cell. I would suggest to to file your requirement at https://influence.sap.com/.

In the meantime as always I am curious what other ideas the community comes up with to help you.

JBARLOW
Contributor
0 Kudos

Thanks Bob,

Let's assume that there won't be a click on header cells, in that scenario how could we get it working?

Bob0001
Advisor
Advisor
0 Kudos

Like you described it above: for data cells use getData and for header cells use getResultMember.