in datatable if press shift than record selected and get rows id

in datatable if press shift than record selected and get rows id

hvmhvm Posts: 26Questions: 0Answers: 0

hi,
my client want if i press shift and select record even in other page also than i get all record list.
so is this possible in datatables?

thanks in advance....

Replies

  • hvmhvm Posts: 26Questions: 0Answers: 0

    hi it means if i select record from first page and press shift key and click on 3rd page and there select first 4 rows than i can get all records of first page, all records of second page and first 4 record of 3rd page.

  • allanallan Posts: 63,488Questions: 1Answers: 10,467 Site admin

    Seems to work okay, as you describe it, for me in this example: https://datatables.net/release-datatables/extensions/TableTools/examples/select_os.html.

    Allan

  • hvmhvm Posts: 26Questions: 0Answers: 0
    edited May 2014

    hi allan,
    thanks for your reply but in my demo page its not working.
    In my demo page data would be fetch from server side. i also update datatable version of 1.10.
    may be if server side event true than this not worked else it would worked.

    $(document).ready(function() {
    var selected = [];
    var oTable = $('#myDataTable').dataTable({
    dom: 'T<"clear">lfrtip',
    tableTools: {
    "sRowSelect": "os",
    "aButtons": ["select_all", "select_none"]
    },
    "oColVis":
    {
    "activate": "mouseover",
    "buttonText": "Change columns",
    },
    "oColReorder": {

        },
        "sScrollX": "100%",
        "sScrollXInner": "150%",
        "bScrollCollapse": true,
        "bPaginate": true,
        "bStateSave": false,
        "sPaginationType": "full_numbers",
        "bAutoWidth": true,
        "bJQueryUI": false,
        "bLengthChange": true,
        "bServerSide": true,
        "sAjaxSource": "Home/AjaxHandler",
        "bProcessing": true,
        "aoColumns": [
            {
                "sName": "ID",
                "bSearchable": false,
                "bSortable": false,
                "fnRender": function(oObj) {
                    return '<a href="#" class="myClass">View</a>';
                }
            },
            { "sName": "COMPANY_NAME" },
            { "sName": "ADDRESS" },
            { "sName": "TOWN" }
        ],
       "rowCallback": function( row, data, displayIndex ) {
            if ( $.inArray(data.DT_RowId, selected) !== -1 ) {
                $(row).addClass('row_selected');
            }
        }
    });
    
    $('#myDataTable tbody').on('click', 'tr', function () {
        var id = this.id;
        var index = $.inArray(id, selected);
    
        if ( index === -1 ) {
            selected.push( id );
        } else {
            selected.splice( index, 1 );
        }
    
        $(this).toggleClass('row_selected');
    } );
    

    });

This discussion has been closed.