Select a row which has a class already

Select a row which has a class already

GeoffreyGeoffrey Posts: 19Questions: 5Answers: 0

Hello, I would like to know how to change the style of the row when you click on it, and there is already a background-color on the row. I used the "select function"

Here is an example: http://live.datatables.net/qalujigo/1/edit

Apparently, the row is selected, but the user can't see that the row is selected ...

Also, is it possible to change the font weight in bold ?
And to create a button that "clear" all the selected row ? (Because I don't want that the user need to click on each row that he selected before to unselect all of them.)

Geoffrey

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,771Questions: 1Answers: 10,510 Site admin
    Answer ✓

    If you are using the background colour for something else, then you need some other way to indicate that the row is selected. You could use the checkbox options in Select to do that for example.

    Also, is it possible to change the font weight in bold ?

    Yes - the CSS font-weight option would be used for that.

    And to create a button that "clear" all the selected row ? (Because I don't want that the user need to click on each row that he selected before to unselect all of them.)

    If you were using the Select extension you can use rows().deselect() to do that. You don't appear to be using Select though, so you would need some custom code.

    Allan

  • GeoffreyGeoffrey Posts: 19Questions: 5Answers: 0

    Ok thanks, I didn't know about the select extension... I use it now, but how is it possible to change the class .....

    Here what I did:

    // inside datatable function
    ...
    select: {
                    style: 'multi',
                    className: 'selected_row'
                },
    ...
    
    // inside CSS
    ...
        tr.selected_row td{
            font-weight:"bold" !important;
        }
    ...
    

    I used Firebug to see that this is working, I mean, I saw that:
    <tr class="odd row_red selected_row" role="row" style="height: 35px;">

    Also, I can get the value of each selected row

    var liste_num_iple=new Array();
            for(var i=0;i<table_liste_materiel.rows( { selected: true } ).data().length;i++){
                liste_num_iple.push(table_liste_materiel.rows({selected: true}).data()[i][0]);
            }
    

    But the row is not in bold ! Please can you explain me, why ?

    Geoffrey

  • allanallan Posts: 63,771Questions: 1Answers: 10,510 Site admin
    Answer ✓

    font-weight:"bold"

    I don't believe that is valid CSS. Use just:

    font-weight:bold
    

    Allan

  • GeoffreyGeoffrey Posts: 19Questions: 5Answers: 0

    ok ... thank you XD
    sorry ... ;)

This discussion has been closed.