view raw
Shere Shere - 6 months ago 41
CSS Question

Change richselect's input color

I wonder if it's possible to change the input's color in runtime.

Here's my select (Webix ui.richselect):

view:"richselect", label:"Status", options:[
{ id:1, value:"Done", $css:"done" },
{ id:2, value:"Processing", $css:"process" },
{ id:3, value:"On hold", $css:"on-hold" },
{ id:4, value:"Failed", $css:"failed" },
onChange:function(newV, oldV){
webix.message("Status changed to "+this.getList().getItem(newV).value)

key related to the CSS class that is applied to the item.

.webix_list_item.done {
<!-- . . . -->
.webix_list_item.webix_selected {

After changing the richselect's value, I need to set the background color of the newly selected item as the background color of the richselect.

In my opinion, it can be done through the
event, but I have no idea how exactly I can solve it.

Any suggestions? Thanks in advance.


Thanks @Nikhil for the answer, it helped me to apply my combo logic on the richselect in the webix way.

So, the difference was that in the combo i was applying the style on the input and it was working but for the richselect applying the style on input was wrong rather i have to apply on the .webix_inp_static .

1. CSS

In your style for each of your custom css on webix_list_item you have to also add css for .webix_inp_static as shown:

  .done .webix_inp_static,.webix_list_item.done { 

2. onChange function

You have to removeCss on the oldV if existing and addCss on the newV as:

onChange:function(newV, oldV){ 
         if(oldV) webix.html.removeCss(this.getNode(), this.getList().getItem(oldV).$css);   
         if(newV) webix.html.addCss(this.getNode(), this.getList().getItem(newV).$css);            

Please check the snippet here.