This is a migrated thread and some comments may be shown as answers.

Can I change style or css for each item in listbox?

1 Answer 253 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Warren
Top achievements
Rank 1
Warren asked on 18 Apr 2014, 01:37 AM
Hello,

I am listing items with checkboxes and I would like to use the strikethrough on the text of an item when the checkbox is checked. Kind of like a ToDo list and marking them completed. I also need to change it back when unchecking it. And I want to load the data that way. I guess I can always loop through and check to mark them and apply the css if needed.

Would this be easier to do with a gridview control also especially since I am data binding it?

Thanks,
Warren


1 Answer, 1 is accepted

Sort by
0
Magdalena
Telerik team
answered on 21 Apr 2014, 07:44 AM
Hi Warren,

The strike-through can be achieved by adding and removing CSS class which has the property text-decoration set to line-through. Please, try to apply the following:

ASPX
<telerik:RadListBox runat="server" CheckBoxes="true" OnClientItemChecked="OnClientItemCheckedHandler">

JavaScript
function OnClientItemCheckedHandler(sender, eventArgs) {
    $ = $telerik.$;
    var strikethroughClassName = "strikethrough";
    var item = eventArgs.get_item();
 
    if (item.get_checked()) {
        $(item.get_element()).addClass(strikethroughClassName);
    }
    else {
        $(item.get_element()).removeClass(strikethroughClassName);
    }
             
}

CSS
.strikethrough {
    text-decoration: line-through;
}


Regards,
Magdalena
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ListBox
Asked by
Warren
Top achievements
Rank 1
Answers by
Magdalena
Telerik team
Share this question
or