Search code examples
cssdatatablewebix

How to partly change the font of a webix datatable cell?


I have below datatable in which one of the cells (1st row, Message column) is colored. All the cells under the Message column is showing a multiline message.

Snippet : https://webix.com/snippet/cf9d8a62

Instead of coloring the entire cell, I want the font of one of the items to be colored or bold. For example, I want only the 'world' in that cell to be colored as green or as bold.

Can this be done ? Please help.

Thanks.


Solution

  • You could use Template literals here and modify your for loop.

    for(var i in p_list) {
     var item = p_list[i];
     if (item === 'world') {
       item = `<span style="color:green;font-weight:bold">o ${item}</span>`;
    
       /* 
       or you can give it a class and style the item accordingly in css
       item = `<span class="green">o ${item}</span>`;
       */
    
     } else {
       item = `<span>o ${item}</span>`;
     }
    
       e_item += item + "<br>";
     }