/* ------------------------------------------------------------------------------
*
*  # Fixed Columns extension for Datatables
*
*  Specific JS code additions for datatable_extension_fixed_columns.html page
*
*  Version: 1.0
*  Latest update: Aug 1, 2015
*
* ---------------------------------------------------------------------------- */

$(function() {

// clearInterval(timeTicket);
// var timeTicket = setInterval(function () {
		
		$.ajax({
         	url: "variabletable/datameter",
         	type:"post",
         	data:"",
         	success: function(data) {
           		
				databaru = JSON.parse(data);

    			// Left and right fixed columns
    			$('.datatable-fixed-both').DataTable({
        				destroy: true,		
						data: databaru,
						paging: true,
        				scrollX: true,
						columnDefs: [
								{
									visible: true, 
									targets: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,
											 26,27,28,29,30,31,32,33,34,35, 36]
								},
            					{ 
                				  	width: "20px",
                					targets: [0]
           						},
            					{ 
                				  	width: "200px",
                					targets: [1]
            					},
            					{ 
                				  	width: "100px",
                					targets: [2]
            					}
						],
						dom: 'Bfrtip',
						        buttons: [
						            'copy', 'csv', 'excel', 'print'
						        ],
        				fixedColumns: {
            				leftColumns: 1,
							leftColumns: 2
        				}
					
    			}); 	
				      
            }  
                  
      	  });
		  
		  
	
				
//	 }, 2000);  
	 




   // Table setup
    // ------------------------------

    // Setting datatable defaults
    $.extend( $.fn.dataTable.defaults, {
        destroy: true,
		dom: '<"datatable-header"fl><"datatable-scroll"t><"datatable-footer"ip>',
		
        language: {
            search: '<span>Filter:</span> _INPUT_',
            lengthMenu: '<span>Show:</span> _MENU_',
            paginate: { 'first': 'First', 'last': 'Last', 'next': '&rarr;', 'previous': '&larr;' }
        }
    });
	
	
	// Define default path for DataTables SWF file
    $.fn.dataTable.TableTools.defaults.sSwfPath = "assets/swf/datatables/copy_csv_xls_pdf.swf"


    // Tabletools defaults
    $.extend(true, $.fn.dataTable.TableTools.classes, {
        "container" : "btn-group conbar DTTT_container", // buttons container
        "buttons" : {
            "normal" : "btn btn-warning btn-block ", // default button classes
            "disabled" : "disabled" // disabled button classes
        },
        "collection" : {
            "container" : "dropdown-menu" // collection container to take dropdown menu styling
        },
        "select" : {
            "row" : "success" // selected row class
        }
    });


    // Collection dropdown defaults
    $.extend(true, $.fn.dataTable.TableTools.DEFAULTS.oTags, {
        collection: {
            container: "ul",
            button: "li",
            liner: "a"
        }
    });



	



    // External table additions
    // ------------------------------

    // Add placeholder to the datatable filter option
    $('.dataTables_filter input[type=search]').attr('placeholder','Type to filter...');


    // Enable Select2 select for the length option
    $('.dataTables_length select').select2({
        minimumResultsForSearch: "-1"
    });
	 

    
});
	
	
