We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Rowdatabound or querycellinfo on a listbox ?

Hello,
Is it possible to add conditionnal color to an item in a list box ? If my item's text is 'Hello' I want the background of the item in a certain color.

Thanks

1 Reply

DL Deepa Loganathan Syncfusion Team January 16, 2019 04:28 PM UTC

Hi Julien,  
 
You can achieve this requirement to highlight items with specific text in the create event of Listbox, once the listbox items are rendered and available for customization as given in the below code.  
 
 
$("#selectbike").ejListBox({ 
                dataSource: BikeList, 
                create: create, 
                fields: { id: "empid", value: "text" } 
            }); 
 
 
function create(args){ 
         var list =  $("#selectbike").find("li"); 
           $.map(list, function (obj, index) { 
          if(obj.innerText =="Hello"){ 
              $(obj).addClass("highlight"); 
          } 
          }); 
        } 
 
<style type="text/css" class="cssStyles"> 
        .highlight { 
            background-color: beige; 
        } 
</style> 
 
 
We have prepared a sample for your reference. Please check the below JSPlayground link. 
 
 
Regards,  
Deepa L. 


Loader.
Live Chat Icon For mobile
Up arrow icon