Highlighting selected row

Highlighting selected row

genesys_kumargenesys_kumar Posts: 24Questions: 6Answers: 0

Code Link: https://github.com/ramkumar2325/DataTable_Sample

I have uploaded source code here, issue is when I click any row it is not highlighting. Initially, it worked but after sometime it stopped working.

can someone please help me with this issue.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,315Questions: 26Answers: 4,948
    Answer ✓

    I guess you are referring to this code:

                    $('#agentSelectionTable tbody').on('click', 'tr', function () {
                        if ($(this).hasClass('selected')) {
                            $(this).removeClass('selected');
                        } else {
                            table.$('tr.selected').removeClass('selected');
                            $(this).addClass('selected');
                        }
                    });
    

    It doesn't look like you are using the Select extension. Since you are not using the select extension then you will need to add CSS to your style to highlight the rows. See this example that highlights when hovering:
    http://live.datatables.net/digeseka/1/edit

    You will need something similar, just remove the hover from the CSS.

    Kevin

  • genesys_kumargenesys_kumar Posts: 24Questions: 6Answers: 0

    Hi Kevin,

    Below code working when i set "Datatable" style = display. But in my code, i set it with "compact". Anyway i used the style model as you given.

    $('#agentSelectionTable tbody').on('click', 'tr', function () {
    if ($(this).hasClass('selected')) {
    $(this).removeClass('selected');
    } else {
    table.$('tr.selected').removeClass('selected');
    $(this).addClass('selected');
    }
    });

    Thanks,
    Kumar

Sign In or Register to comment.