Pogledajte određenu poruku
Staro 27. 02. 2015.   #5
mslavko
profesionalac
Professional
 
Avatar mslavko
 
Datum učlanjenja: 25.10.2012
Poruke: 278
Hvala: 16
32 "Hvala" u 9 poruka
mslavko is on a distinguished road
Default

Kd:
var ajdi = 0;
var ajdipar = 0;
var akt ='';
$(document).ready(function() {
    drawVisualization();
 
    });
function drawVisualization() {
     
               $('#example').DataTable({
                             "ajax": {
            "url": 'getFin.php',
            "type": 'POST',
            "dataSrc": function (json) {
                if(!json.data){
               
            $('#myModal').modal('show');
            //$('.analize').hide();
            json.data = [];
        }
                return json.data;
            }
        },
                    paging: false,
                    //"dom":' <"search"f><"top"l>rt<"bottom"ip><"clear">',
                    "oLanguage": {
    "sInfo": 'Ukupno _END_ transakcija.',
    "sInfoEmpty": 'Nema zabelezenih transakcija',
    "sEmptyTable": "Nema transakcija, dodajte klikom na dugme 'Dodaj kupoprodaju'.",
},
                    "columns": [{
                            "data": "ID"
                        }, {
                            "data": "datum"
                        }, 
                        {
                            "data": "datum_dospeca"
                        },{
                            "data": "aktivnost"
                        },
                        
                        {
                            "data": "vrsta"
                        },
                        {
                            "data": "artikl"
                        },
                        
                        {
                            "data": "6"
                        },
                         {
                            "data": "7"
                        },{
                            "data": "8"
                        },
                         {
                            "data": "dobavljac"
                        },
                        {
                            "data": "nacin_placanja"
                        },
                        {
                            "data": "skladiste"
                        },
                        {
                            "data": "akcija"
                        },
                         {
                            "data": "jmere"
                        },
                        {
                            "data": "porez"
                        },
                         {
                            "data": "opis"
                        }
                    ],
                     "fnFooterCallback": function (nRow, aasData, iStart, iEnd, aiDisplay) {

        var columnas = [6, 7, 8]; //the columns you wish to add            
        for (var j in columnas) {
            var columnaActual = columnas[j];
            var total = 0;
            for (var i = iStart; i < iEnd; i++) {
                total = total + parseFloat(aasData[aiDisplay[i]][columnaActual]);
            }
            $($(nRow).children().get(columnaActual-1)).html(total);

        }
    }, 
                    "columnDefs": [
                            {
                        "targets": [0,13,14,15],
                        "visible":false
                            },
                         {
                        "targets": 12,
                        "data": "akcija",
                        "render": function(data, type, full, meta) {
                            // return data; 
                            return '<div style="float:right;"><button class="btn btn-info troskovnik" data-toggle="modal" data-target="#update">Detalji...</button> <i  data-toggle="modal" data-target="#delete" class="fa fa-times"></i></div>';
                        }
                            },
                              { 
                        "targets": 3,
                        "data": "aktivnost",
                        "render": function(data, type, full, meta) {
                            if (data=='prodaja') {
                            return '<button class="btn btn-success">'+data+'</button>';
                            } else if (data=='kupovina'){
                                                        return '<button class="btn btn-danger" >'+data+'</button>';

                            } else {
                                                        return '<button class="btn btn-info" >'+data+'</button>';

                            }
                            
                            }
                              }
                           
                
    ]
                });
            
            var dataTable = $('#example').dataTable();
    $("#searchbox").keyup(function() {
        dataTable.fnFilter(this.value);
    }); 
    
            };


 $(document).ready(function(){
 var oTable =  $('#example'). dataTable();
 
$('#example').on('click', 'tr', function(){
    var oData = oTable.fnGetData(this);
    console.log(oData.ID);
    ajdi = oData.ID;
    $('#naziv1').val(oData.naziv);
    $('#ha1').val(oData.ha);
    $('#ar1').val(oData.ar);
    $('#m21').val(oData.m2);
    $('#kultura1').val(oData.kat_kul);
    $('#osnov1').val(oData.osnov);
    $('#lokacija1').val(oData.lokacija);
    $('#opis1').val(oData.opis);
    $('#select2-kulb1-container').text(oData.planirana_kul);
});
$("#brisi").click(function() {

        $.ajax({
            url: "delete.php",
            type: "POST",
            async: true, 
            data: { vrednostid:ajdi}, //your form data to post goes here as a json object
            dataType: "html",

            success: function(data) {
              $('#delete').modal('hide');
                $('#example').dataTable().fnDestroy();
		drawVisualization();   
            },
             error: function(data) {
         console.log(data);
             }
        });
   
});
$('#myModal1').on('shown.bs.modal', function (e) {
  
    drawInputi();
    
});


    });
a HTML je:

Kd:
<table id="example" class="table table-striped table-bordered table-responsitive" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>ID</th>
                <th>Datum</th>
                <th>Dospece</th>
                <th><i class="fa fa-random"></i></th>
                <th>Vrsta</th>
                <th>Artikl</th>
                <th>Kolicina</th>
                <th>Iznos</th>
                <th>Placeno</th>
                <th>Kome/Od koga</th>
                <th>Placanje</th>
                <th>Skladiste</th>
                <th></th>
            </tr>
        </thead>
 
        <tfoot>
            <tr>
               <th>ID</th>
                <th>Datum</th>
                <th>Dospece</th>
                <th><i class="fa fa-random"></i></th>
                <th>Vrsta</th>
                <th>Artikl</th>
                <th>Kolicina</th>
                <th>Iznos</th>
                <th>Placeno</th>
                <th>Kome/Od koga</th>
                <th>Placanje</th>
                <th>Skladiste</th>
                <th></th>
            </tr>
        </tfoot>
    </table>
mslavko je offline   Odgovorite uz citat