partstable fixed matrici dropdown

This commit is contained in:
Claudio 2025-10-28 09:31:13 +01:00
parent 8d6fe92481
commit 9969cc9edc

View File

@ -1474,8 +1474,8 @@ $(document).ready(function () {
}, },
}); });
// Ripristina il valore se valido // === MODIFICA CHIRURGICA: solo qui ===
if (partId && partId !== "new" && currentValue) { if (currentValue && currentValue !== "new") {
const matrice = matrici.find((m) => m.IdMatrice == currentValue); const matrice = matrici.find((m) => m.IdMatrice == currentValue);
if (matrice) { if (matrice) {
const option = new Option( const option = new Option(
@ -1487,11 +1487,15 @@ $(document).ready(function () {
$select.append(option).trigger("change"); $select.append(option).trigger("change");
partMatrice[partNumber] = matrice.IdMatrice; partMatrice[partNumber] = matrice.IdMatrice;
} else { } else {
// Aggiusta valore non valido
$select.val(null).trigger("change"); $select.val(null).trigger("change");
partMatrice[partNumber] = null; partMatrice[partNumber] = null;
} }
} else {
// Nessun valore: assicurati che sia vuoto
$select.val(null).trigger("change");
partMatrice[partNumber] = null;
} }
// === FINE MODIFICA ===
$select.on("change", function () { $select.on("change", function () {
const idmatrice = $(this).val(); const idmatrice = $(this).val();