57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
/*let table = new Tabulator("#shopping_cart_table", {
|
|
layout:"fitColumns",
|
|
columns:[
|
|
{title:"Produkte", field:"col1", headerSort:false},
|
|
{title:"zusammen mit", field:"col2", headerSort:false},
|
|
],
|
|
});
|
|
|
|
|
|
function updateShoppingCartTable(id) {
|
|
if (typeof id !== 'undefined') {
|
|
request('shopping_cart', id).then(function () {
|
|
table.setData("/bauDas/shopping_cart?id="+id);
|
|
});
|
|
} else request('shopping_cart').then(function () {
|
|
table.setData();
|
|
});
|
|
}*/
|
|
|
|
let shopping_cart_result;
|
|
|
|
function updateShoppingCartTable(id) {
|
|
if(typeof id !== 'undefined') {
|
|
request('shopping_cart', id).then(function (data) {
|
|
shopping_cart_result = data;
|
|
drawShoppingCartTable();
|
|
});
|
|
}else request('shopping_cart_result').then(function(data) {
|
|
shopping_cart_result = data;
|
|
drawShoppingCartTable();
|
|
});
|
|
}
|
|
|
|
function drawShoppingCartTable(){
|
|
let table = document.getElementById("shopping_cart_table");
|
|
while(table.hasChildNodes()){
|
|
table.removeChild(table.firstChild);
|
|
}
|
|
|
|
let row = $("<thead>");
|
|
row.append("<tr>");
|
|
row.append("<th>Artikel</th>");
|
|
row.append("<th>Wird häufig zusammen gekauft mit</th>")
|
|
row.append("</tr>");
|
|
row.append("</thead>");
|
|
row.append("<tbody>");
|
|
for (x in shopping_cart_result){
|
|
row.append("<tr>");
|
|
row.append("<td>" + shopping_cart_result[x].col1 + "</td>");
|
|
row.append("<td>" + shopping_cart_result[x].col2 + "</td>");
|
|
row.append("</tr>");
|
|
}
|
|
row.append("</tbody>");
|
|
$("#shopping_cart_table").append(row);
|
|
}
|
|
|