add style

1)can I set conditional background-color directly or by a easy way?
$$(“ssheet”).conditions.add(3,6,">",100,"{background:red}");

2)how can I set font’s color of some columns by a easy way?
by setRangeStyle or add a className(with specified style)

3)how to add tooltips(=value) for all the cells and headers?

thank you so much!

Hi @zzhang

can I set conditional background-color directly or by a easy way?

You can try to use webix.html.createCss.

Example: https://snippet.webix.com/r07m2wxs

how can I set font’s color of some columns by a easy way?

It’s need to add style via addStyle() and set it to the column via setRangeStyle()

Check this snippet: https://snippet.webix.com/lh7ma639

how to add tooltips(=value) for all the cells and headers?

For header of the inner datatable you need to iterate through columns and update tooltips. To add tooltips for newly created columns you need to attach onChange event.
For cells you need to use define({tooltips:true}).

Example: https://snippet.webix.com/4cm79oqk

hi Dima_S,
about how to add tooltips for column headers,I think it is better with:

on:{
    onColumnInit: (col) => {
      //add tooltip for column headers
      col.header.tooltip = true;
    }
  }

please check https://snippet.webix.com/jn2pu0yt

@zzhang

Yes, you are right, it’s better to use onColumnInit event

about add css for cells,I wonder which way is best:

my needs: set different styles(color/text-align/font-family/…) for different columns or rows.

1):with array styles[] when init sheet
like https://snippet.webix.com/rnj0haca

2):with function addStyle such as:
https://snippet.webix.com/h2iba8d8

3)or could I add className for cells? then i can add whatever styles I need

thanks a lot. have a good day!

about conditional background color

  1. in this demo, the background color should be blue(>10)
    https://snippet.webix.com/rbukp6zq
    but the result is yellow, seems like the condition2 is replaced with condition3.Then the condition2 is gone.
    Do I need to add conditions by order? or this is a bug?

2.And why doesn’t support ‘>=’ or ‘<=’ ,it is troublesome to add twice.

@zzhang

about add css for cells,I wonder which way is best

It depends on whether the number of rows / columns will change. If the number does not change use first variant, otherwise second.

or could I add className for cells? then i can add whatever styles I need

You can use datatable addCellCss() method.

about conditional background color

in this demo, the background color should be blue

There are conflicting conditions in this example (>1, >5, >10). Therefore, the last matching is used (10 > 5).

Check the improved example: https://snippet.webix.com/wl5dqnyu

And why doesn’t support ‘>=’ or ‘<=’ ,it is troublesome to add twice.

Thanks for the suggestion, we will consider adding these parameters.

about add css for cells with array styles[] when init sheet;
1)in my demo, https://snippet.webix.com/uup1jer6
Cells has same styles(“blue;pink”) but one different style,
then I need to define two styles ss1 and ss2.
I wonder if there is another esay way to do this?

  1. in this demo https://snippet.webix.com/p8z1xit1
    I set a percentage,then export to excel the value is shown ‘325.69%’ it is right.
    But I put this codes in my project as a react component,then export to excel the value is shown ‘3.26%’. Have you ever encountered this problem? thanks a lot.
    by the way, versions:"@xbs/spreadsheet": “^6.3.3”, “@xbs/webix-pro”: “^6.3.3”,

@zzhang

Cells has same styles(“blue;pink”) but one different style, then I need to define two styles ss1 and ss2.

Yes, you need to define two styles.

But I put this codes in my project as a react component,then export to excel the value is shown ‘3.26%’. Have you ever encountered this problem? thanks a lot.

I inserted into this demo spreadsheet and everything seems to work fine. You can contact support@webix.com to get an example based on this demo.