autonumeric

This commit is contained in:
amazuecos
2025-02-05 04:17:52 +01:00
parent b67b41148b
commit 23a6e4e8e5
10 changed files with 224 additions and 46 deletions

View File

@ -115,11 +115,21 @@
table : "#tableOfTarifamanipuladolineas",
idSrc: 'id',
fields: [ {
name: "tirada_min"
name: "tirada_min",
attr: {
type: "text",
name : "tirada_min",
class :"autonumeric"
}
}, {
name: "precio_max"
}, {
name: "tirada_max"
name: "tirada_max",
attr: {
type: "text",
name : "tirada_max",
class :"autonumeric"
}
}, {
name: "precio_min"
}, {
@ -137,7 +147,36 @@
]
} );
editor.on('open',(event)=>{
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if(autoNumericInstance){
autoNumericInstance.remove()
}
new AutoNumeric(this, {
decimalCharacter: ",",
decimalPlaces : 0,
digitGroupSeparator: ".",
unformatOnSubmit : true,
});
})
})
editor.on( 'preSubmit', function ( e, d, type ) {
if (d.data) {
Object.keys(d.data).forEach(function (key) {
// Find all elements with class .autonumeric
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (autoNumericInstance) {
// Get raw value and update the corresponding field
let rawValue = autoNumericInstance.getNumericString();
d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used
}
});
});
}
if ( type === 'create'){
d.data[0]['tarifa_manipulado_id'] = id;
}
@ -184,9 +223,9 @@
async: true,
}),
columns: [
{ 'data': 'tirada_min' },
{ 'data': 'precio_max' },
{ 'data': 'tirada_max' },
{ 'data': 'tirada_min',render : (d) => `<span class="autonumeric">${d}</span>` },
{ 'data': 'precio_max', },
{ 'data': 'tirada_max',render : (d) => `<span class="autonumeric">${d}</span>` },
{ 'data': 'precio_min' },
{ 'data': 'margen' },
{
@ -245,7 +284,14 @@
);
} );
theTable.on('draw',() => {
AutoNumeric.multiple("span.autonumeric", {
digitGroupSeparator: ".",
decimalCharacter: ",",
decimalPlaces : 0,
unformatOnSubmit: true
});
})
// Delete row
$('#tableOfTarifamanipuladolineas').on( 'click', 'tbody span.remove', function (e) {