Skip to Content
0

is it possible to set css by script in sap design studio?

Dec 23, 2016 at 05:45 AM

202

avatar image

As follow picture,I want the bubble color auto changed by data,eg:if the value>0 the color red,else the color blue.

I've use follow code to get data,but if I follow like this,all of bubble will red or blue,not like I want just value less than 0.

How can I do to make it realize?Just the value greater than 0 will red,and others blue?

var va=DS_1.getMembers("ZCQYF", 2000);
va.forEach(function(element, index) {
var v=DS_1.getData("OVERDUE_TTL", {"ZCQYF": element.internalKey}).value;
LISTBOX_1.addItem(v+"", v+"");
 if(v>=0){
   LISTBOX_1.setCSSClass("red");
 }else if(v<0){
  LISTBOX_1.setCSSClass("blue");
 }
});

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Vidhya V Dec 27, 2016 at 08:18 AM
0

Hi jing,

How are you using Geo or Leaflet Map??

If leaflet map, Please refer the below URL,

https://blogs.sap.com/2016/01/07/design-studio-16-sdk-leaflet-maps-for-more-mapping-goodness/

Regards,

Vidhya.C

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Vidhya.

I'm use Geo Map.I've view the url that you recommend ,but I still like use Geo Map,which bubble maybe more suit to my situation.

Thanks.

Jing

0
Mustafa Bensan Dec 27, 2016 at 12:42 PM
0

Hi Jing,

The scenario you have documented is confusing. It appears that you would like to dynamically change the bubble colours in a geo map via CSS yet your script example is changing the CSS applied to a List Box. Can you clarify?

Regards,

Mustafa.

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hi Mustafa.

It's my typo.the code I was used for a List Box,but if I change the LISTBOX_1.setCSSClass("red") to GEOMAP_1.setCSSClass("red") ,it's same mean.So it isn't matter to my result.

And follow code was I changed ,if I add element by html,it's ok.I hope this can help some new ideas.

Thanks.

Jing

var result="";
var va=DS_1.getMembers("ZCQYF", 2000);
va.forEach(function(element, index) {
var v=DS_1.getData("OVERDUE_TTL", {"ZCQYF": element.internalKey}).value;
var style="";
 if(v>=0){
result=result+"<span>"+v+"</span><br/>";
 }else{
result=result+"<span class='red'>"+v+"</span><br/>";
 }
});
FORMATTEDTEXTVIEW_1.setHtmlText(result);
0

Hi Jing,

I don't see how your script code above relates to the Geo Map component. It looks like the script is generating formatted HTML text which is completely unrelated to the Geo Map. Also, it would be helpful if you provided the custom CSS file you are using where you have defined the "red" CSS class.

Regards,

Mustafa.

1

Hi Mustafa.

Maybe I'm not express clear.

I want to realize a situation in geomap that when the data less than 0,then "red",else "blue".Above code is just an eg to show that is a way to realize color according to data.But if I use geomap,I can't use html,so whether there have another way to realize color changed by data?

Thanks .

Jing

0