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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Rowdatabound or querycellinfo on a listbox ?

Thread ID:

Created:

Updated:

Platform:

Replies:

142041 Jan 16,2019 10:31 AM UTC Jan 16,2019 04:28 PM UTC ASP.NET MVC 1
loading
Tags: ListBox
Julien Breton
Asked On January 16, 2019 10:31 AM UTC

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

Deepa Loganathan [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;