(X)HTML, JavaScript, DHTML, XML, CSS Client scripting tehnologije, Dynamic HTML, Cascading Stylesheets, XML i standardi |
|
Alati teme | Način prikaza |
|
27. 02. 2015. | #1 | ||
profesionalac
Professional
Datum učlanjenja: 25.10.2012
Poruke: 278
Hvala: 16
32 "Hvala" u 9 poruka
|
DataTable destroy
Koristim DataTable plugin i imam tabelu example
Moram da je 'unistim' pa sam napisao: Kôd:
$('#example').dataTable().fnDestroy(); Citat:
Pokusao sami sa veliko 'D': Kôd:
$('#example').DataTable().fnDestroy(); Citat:
|
||
27. 02. 2015. | #2 |
banned
Professional
Datum učlanjenja: 04.06.2005
Poruke: 371
Hvala: 0
738 "Hvala" u 83 poruka
|
__________________
Don't look at me; I'm lost too. “If you can't dazzle them with brilliance, baffle them with bul*s**t.” |
"Hvala" Br@nkoR za poruku: |
27. 02. 2015. | #3 |
profesionalac
Professional
Datum učlanjenja: 25.10.2012
Poruke: 278
Hvala: 16
32 "Hvala" u 9 poruka
|
Problem je sto na ostalim stranama ova funcija radi samo na jednoj ne, a ne znam razlog
|
27. 02. 2015. | #4 |
banned
Professional
Datum učlanjenja: 04.06.2005
Poruke: 371
Hvala: 0
738 "Hvala" u 83 poruka
|
Postavi link do te stranice, kod ili postavi npr. na jsfiddle ili neki drugi servis.
__________________
Don't look at me; I'm lost too. “If you can't dazzle them with brilliance, baffle them with bul*s**t.” |
27. 02. 2015. | #5 |
profesionalac
Professional
Datum učlanjenja: 25.10.2012
Poruke: 278
Hvala: 16
32 "Hvala" u 9 poruka
|
Kôd:
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(); }); }); Kôd:
<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> |
27. 02. 2015. | #6 | |
profesionalac
Professional
Datum učlanjenja: 25.10.2012
Poruke: 278
Hvala: 16
32 "Hvala" u 9 poruka
|
Takodje getFin.php generise JSON podatke:
Citat:
|
|
27. 02. 2015. | #7 |
banned
Professional
Datum učlanjenja: 04.06.2005
Poruke: 371
Hvala: 0
738 "Hvala" u 83 poruka
|
U columns imaš definisano 16 kolona, a u html kodu umaš 13, dodaj još 3 polja koja nedostaju.
Ili pogledaj npr. http://stackoverflow.com/a/26483798
__________________
Don't look at me; I'm lost too. “If you can't dazzle them with brilliance, baffle them with bul*s**t.” |
28. 02. 2015. | #8 |
profesionalac
Professional
Datum učlanjenja: 25.10.2012
Poruke: 278
Hvala: 16
32 "Hvala" u 9 poruka
|
Hvala PUNo! Nemogu da verujem kakvu sam gresku prevideo!
|
|
|