How to get the selected Row jquery datatables

Asked

Viewed 2,400 times

0

have my grid:

    $.fn.dataTable.ext.legacy.ajax = true;
    var grid = $("#gridGrupo").dataTable({
        "language": {
            "url": "/Scripts/Libs/DataTables/ptBr.txt"
        },
        "processing": true,
        "serverSide": true,
        "ajax": "/grupo/data",
        "order": [[0, "desc"]],
        "columns": [
            { "data": "Id" },
            { "data": "Nome", },
            { "data": "Descricao" }
        ]
    });
    $('#gridGrupo tbody').on('click', 'tr', function () {
        if ($(this).hasClass('row_selected')) {
            $(this).removeClass('row_selected');
        }
        else {
            grid.$('tr.row_selected').removeClass('row_selected');
            $(this).addClass('row_selected');
        }
    });

It arrow the class "row_selected" when it selects a line

I have my job

function Editar(){
}

I need to take the line that he selected, which has the class "row_selectd" to get the id, and if not find, send an msg

I’m not getting the ID part..

1 answer

0


from what I’ve seen here is simple

using the following command to remove the line can be adapted:

$('#button').click( function () {
        table.row('.selected').remove().draw( false );
    } );

If you need more help go up that part in jsfiddle to help a little more

Browser other questions tagged

You are not signed in. Login or sign up in order to post.