getattribute on selectedrow

getattribute on selectedrow

buraksensozburaksensoz Posts: 1Questions: 1Answers: 0
edited July 2017 in Free community support

hello

i've a problem. i try to get special attribute value.
my code like this
[code]
$(document).ready(function() {
$('#bankatable').DataTable({
"scrollY" : "150px",
"scrollCollapse" : false,
"paging" : false,
"searching" : false,
"info" : false
});

        var table = $('#bankatable').DataTable();

        $('#bankatable tbody').on('mouseenter', 'td', function() {
            var colIdx = table.cell(this).index().row;

            $(table.cells().nodes()).removeClass('highlight');
            $(table.row(colIdx).nodes()).addClass('highlight');
        });
        $('#bankatable tbody tr:eq(0)').addClass('selected');


        $('#bankatable tbody').on('click', 'tr', function() {
            if (!$(this).hasClass('selected')) {
                table.$('tr.selected').removeClass('selected');
                $(this).addClass('selected');
            }
            selectedbankid=this.getAttribute("bankid");
        });

    });

[/code]

i need to use "selectedbankid=this.getAttribute("bankid");" from other function but i can't do this

Thanks for answers

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    you are making it harder than it is. You should be using the Select extention, then you can do something as simple as

    table.on( 'select', function ( e, dt, type, indexes ) {
        if ( type === 'row' ) {
            var node = dt.rows( indexes ).nodes()[0];
           var bid =  $(node).attr("bankid");
    
    // do something with the ID of the selected items
        }
    } );
    
  • bindridbindrid Posts: 730Questions: 0Answers: 119

    Why are you not using the Select extension?

     
    table.on( 'select', function ( e, dt, type, indexes ) {
        if ( type === 'row' ) {
            var node = table.rows( indexes ). nodes()[0];
           var bankid = $(node).attr("bankid');
     
            // do something with the ID of the selected items
        }
    } );
    
  • bindridbindrid Posts: 730Questions: 0Answers: 119

    you are making it harder than it is. You should be using the Select extention, then you can do something as simple as

    table.on( 'select', function ( e, dt, type, indexes ) {
        if ( type === 'row' ) {
            var node = dt.rows( indexes ).nodes()[0];
           var bid =  $(node).attr("bankid");
    
    // do something with the ID of the selected items
        }
    } );
    
  • bindridbindrid Posts: 730Questions: 0Answers: 119

    Why are you not using the Select extension?

     
    table.on( 'select', function ( e, dt, type, indexes ) {
        if ( type === 'row' ) {
            var node = table.rows( indexes ). nodes()[0];
           var bankid = $(node).attr("bankid');
     
            // do something with the ID of the selected items
        }
    } );
    
This discussion has been closed.