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

2 posts, 0 answers
  1. Warren
    Warren avatar
    61 posts
    Member since:
    Aug 2013

    Posted 17 Apr 2014 Link to this post

    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


  2. Magdalena
    Admin
    Magdalena avatar
    421 posts

    Posted 21 Apr 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top