Adding a strike through to a list

Adding a strike through to a list

Pierre-LouisPierre-Louis Posts: 10Questions: 3Answers: 0

is it possible to add a strike though in a list option element ?

Answers

  • kthorngrenkthorngren Posts: 20,369Questions: 26Answers: 4,777
    edited August 2023

    You haven't provided any information in what context you are using the select list. This SO thread shows some options for this. If this doesn't help then please provide more details of how you are using the select list with Datatables or Editor.

    Kevin

  • Pierre-LouisPierre-Louis Posts: 10Questions: 3Answers: 0

    I'm using the options this way:

    `

    function FormatUsersList() {
    var list = [];

    for (let i = 0; i < users.length; i++) {
        list.push({"label": users[i].CodeUtil + " " + users[i].NomPrenom, "value": users[i].IdUtilisateur})
    }
    
    return list;
    

    }

    var formattedUsers = FormatUsersList();

    etapeTableEditor = new DataTable.Editor({
        table: `${selector}`,
        idSrc: 'IdHomologationEtape',
        fields: [
            {
                name: 'IdResp',
                type: 'select',
                options: formattedUsers
            },
    

    `

    I don't see where i can put the line-through css to my element

  • allanallan Posts: 61,822Questions: 1Answers: 10,127 Site admin

    Ah - you mean in the list of options for Editor? For the label use the <s> tag to wrap around the label's text.

    Allan

  • Pierre-LouisPierre-Louis Posts: 10Questions: 3Answers: 0
    edited August 2023

    Am i putting it in the wrong place ?

    function FormatRespToList(type) {
        var list = [];
    
        list.push({ "label": "NR", value: 0 });
        for (let i = 0; i < etapeList.length; i++) {
            if (etapeList[i].Etape == type) {
                let label = etapeList[i].EnrAnnule == 0 ? etapeList[i].CodeUtil + " " + etapeList[i].NomPrenom : "<s>" + etapeList[i].CodeUtil + " " + etapeList[i].NomPrenom + "</s>";
                list.push({ "label": label, "value": etapeList[i].IdResp })
            }
        }
        return list;
    }
    

    Seems like it's interpreted as text

  • allanallan Posts: 61,822Questions: 1Answers: 10,127 Site admin

    Oh! Sorry - this is inside a select option isn't it. I'd been thinking it was a radio for some reason. But I do indeed see the select in the above code.

    In that case, I'm not aware of any way in which this can be done, even outside Editor. The select list options cannot have HTML inside them as you are seeing and the options have extremely limited styling options.

    The only way to do what you are looking for would be to use Select2 or some other HTML based custom dropdown.

    Allan

Sign In or Register to comment.