Button doesn't show up.

Button doesn't show up.

jan.benesjan.benes Posts: 2Questions: 1Answers: 0

I'm loading table through ajax.

    $('#sample_1').dataTable( {
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": baseUrl+"/admin/employee/getusers/type/admin/group/"+groupdata ,
        "aaSorting": [[ 0, "desc" ]],
        "bInfo":false,
        "aoColumnDefs": 
         [
            { "bSortable": false, "aTargets": [1,2,4,5,6,7,8] },
            
         ],
        "iDisplayLength":50,
        "aLengthMenu": [[50, 100, 500, -1], [50, 100, 500, "All"]],
        "fnDrawCallback": function( oSettings ) {
            re_init();
        },
            "language": {
            "lengthMenu": "_MENU_ "+records,
            "sZeroRecords": zerorecord,
            "sSearch":searchv+":",
            "sProcessing":processing+"...",
            "sLoadingRecords":loading+"...",
            "sEmptyTable":emptytable,
            
        },
}

Now I wanted to add button to export some data into excel file, so after the "language" I added

        dom: 'Blfrtip',
        buttons: [
            {
                extend: 'excelHtml5',
                title: 'Report',
                text:"Export",
                exportOptions: {
                    columns: [1,2,3,4,5,6,7,8,9]
                }
            },
        ]

The table shows up. There are no errors, but the button is nowhere to be found. I have very similar export with different table on different site that works perfectly fine.

    $('#sample_1').dataTable( {
        "bProcessing": true,
        "bServerSide": true,
        "bInfo":false,
        "aoColumnDefs": 
         [
            { "bSortable": false, "aTargets": [10] },
            { "bSearchable": false, "aTargets": [0,4,5,6,7,8,9,10] /*Not To include*/ }             
         ],
        "sAjaxSource": baseUrl+"/admin/lectures/getresults",
        "iDisplayLength":50,
        "aLengthMenu": [[50, 100, 500, -1], [50, 100, 500, alls]],
        "fnServerParams": function ( aoData ) {
            if(rl==1){
                aoData.push( {"name":"lectid","value":lectid},{"name":"b_group","value":b_group},{"name":"rl","value":1});
            }else{
                aoData.push( {"name":"lectid","value":lectid},{"name":"b_group","value":b_group});//
            }
        },
        "fnDrawCallback": function( oSettings ) {
            //re_init();
        },
        "language": {
            "lengthMenu": "_MENU_ "+records,
            "sZeroRecords": zerorecord,
            "sSearch":searchv+":",
            "sProcessing":processing+"...",
            "sLoadingRecords":loading+"...",
            "sEmptyTable":emptytable,
        },
        dom: 'Blfrtip',
        buttons: [
            {
                extend: 'excelHtml5',
                title: 'Report',
                text:exportvar,
                exportOptions: {
                    columns: [1,2,3,4,5,6,7,8,9]
                }
            },
        ]
    } );

I didn't write that code originally, but now I'm stuck with it and I'm kind of lost.
Do you have any ideas?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    Can you run the debugger on your page and click the "Upload" option. Then give me the code it gives you for the upload so I can take a look.

    Thanks,
    Allan

  • jan.benesjan.benes Posts: 2Questions: 1Answers: 0

    I used the debbuger and uploaded data, but then I checked some other information about the table and I found out that buttons were missing in the library list. It turned out the guy who wrote the code originally used different series of scripts for different controllers and since he wasn't exporting this table, he didn't think of using the same scripts.

    I just copied the correct scripts with buttons and now everything works fine.

    Thank you.

This discussion has been closed.