add click on row
This commit is contained in:
@@ -1,36 +1,43 @@
|
||||
function getAllData(){
|
||||
$.ajax({
|
||||
|
||||
url: "/getall",
|
||||
type: "get",
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
$(document).ready(function() {
|
||||
|
||||
success: function(response){
|
||||
console.log("1111")
|
||||
let data = response;
|
||||
var table = document.getElementById('alldatable');
|
||||
var tbody = table.getElementsByTagName('tbody')[0];
|
||||
let tableBody = document.getElementById('alldatatable').getElementsByTagName("tbody")[0];
|
||||
tableBody.innerHTML = '';
|
||||
i = 0;
|
||||
|
||||
$.getJSON("/getall", function(data) {
|
||||
$.each(data, function(index, item) {
|
||||
let newRow = tableBody.insertRow(tableBody.rows.length);
|
||||
let cell1 = newRow.insertCell(0);
|
||||
let cell2 = newRow.insertCell(1);
|
||||
let cell3 = newRow.insertCell(2);
|
||||
let cell4 = newRow.insertCell(3);
|
||||
let cell5 = newRow.insertCell(4);
|
||||
let cell6 = newRow.insertCell(5);
|
||||
let cell7 = newRow.insertCell(6);
|
||||
i++;
|
||||
|
||||
cell1.innerText = i;
|
||||
cell2.innerText = item.invNumber;
|
||||
cell4.innerText = item.nazvanie;
|
||||
cell3.innerText = item.kolichestvo;
|
||||
cell5.innerText = item.numberved;
|
||||
cell6.innerText = item.raspologenie;
|
||||
cell7.innerText = item.aud;
|
||||
|
||||
// Clear existing data
|
||||
tbody.innerHTML = '';
|
||||
|
||||
// Loop through the data and create table rows
|
||||
data.forEach(function(item) {
|
||||
var row = document.createElement('tr');
|
||||
Object.values(item).forEach(function(value) {
|
||||
var cell = document.createElement('td');
|
||||
cell.textContent = value;
|
||||
row.appendChild(cell);
|
||||
});
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
})
|
||||
}
|
||||
$(newRow).data('itemData', i);
|
||||
|
||||
|
||||
getAllData()
|
||||
$(newRow).on("click", function() {
|
||||
let ind = newRow.cells[0].innerText;
|
||||
let invNumber = newRow.cells[1].innerText;
|
||||
|
||||
$('#getmodal').modal('show')
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user