Row Selection Not Returning a Row Id

Row Selection Not Returning a Row Id

uptempo777uptempo777 Posts: 5Questions: 4Answers: 0

I'm trying to implement multiple row selection in my table as documented here: http://www.datatables.net/examples/api/select_row.html

I'm using server-side processing so when I send back the JSON result, I include a column named DT_RowId that has the ID of the row I want to identify when selected. I checked the returned JSON and the DT_RowId is showing the Id I intended.

I added this function and it should alert the id (from DT_RowId) but it shows blank:

$('#border tbody').on('click', 'tr', function () {
alert('row clicked');
var id = this.id;
alert(id);
var index = $.inArray(id, selected);

        if ( index === -1 ) {
            selected.push( id );
        } else {
            selected.splice( index, 1 );
        }

        $(this).toggleClass('selected');
    } );

Is this a bug or does someone know what I am doing wrong?

Thanks,
Marvin

Answers

  • uptempo777uptempo777 Posts: 5Questions: 4Answers: 0

    Upon looking at the HTML, the <tr> looks like this:

    <tr role="row" class="odd">

    So it is missing the id that should've have come with DT_RowId. What is the proper way to send back DT_RowId so it gets put into the <tr> of the datatable?

  • uptempo777uptempo777 Posts: 5Questions: 4Answers: 0

    Anyone there to help with my issue? No one has responded in almost 2 months.

This discussion has been closed.