mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
add format number in datatables
This commit is contained in:
@ -182,7 +182,12 @@
|
||||
}, {
|
||||
name: "cp_final"
|
||||
}, {
|
||||
name: "importe_fijo"
|
||||
name: "importe_fijo",
|
||||
attr: {
|
||||
type: "text",
|
||||
name : "importe_fijo",
|
||||
class :"autonumeric"
|
||||
}
|
||||
}, {
|
||||
"name": "tarifa_envio_id",
|
||||
"type": "hidden"
|
||||
@ -195,7 +200,37 @@
|
||||
},
|
||||
]
|
||||
} );
|
||||
editor.on('open', (event) => {
|
||||
$("input.autonumeric").each(function () {
|
||||
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
|
||||
if (autoNumericInstance) {
|
||||
autoNumericInstance.remove()
|
||||
|
||||
}
|
||||
new AutoNumeric(this, {
|
||||
decimalCharacter: ",",
|
||||
digitGroupSeparator: ".",
|
||||
allowDecimalPadding : 'floats',
|
||||
decimalPlaces: 2,
|
||||
unformatOnSubmit: true,
|
||||
});
|
||||
})
|
||||
})
|
||||
editor.on('preSubmit', (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
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
editor.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
@ -255,7 +290,7 @@
|
||||
{ 'data': 'nombre' },
|
||||
{ 'data': 'cp_inicial' },
|
||||
{ 'data': 'cp_final' },
|
||||
{ 'data': 'importe_fijo' },
|
||||
{ 'data': 'importe_fijo',render : (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{
|
||||
data: actionBtns,
|
||||
className: 'row-edit dt-center'
|
||||
@ -346,18 +381,48 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
|
||||
name: "tipo_envio",
|
||||
"type": "select"
|
||||
}, {
|
||||
name: "peso_min"
|
||||
name: "peso_min",
|
||||
attr: {
|
||||
type: "text",
|
||||
name : "peso_min",
|
||||
class :"autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "peso_max"
|
||||
name: "peso_max",
|
||||
attr: {
|
||||
type: "text",
|
||||
name : "peso_max",
|
||||
class :"autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "precio_min"
|
||||
name: "precio_min",
|
||||
attr: {
|
||||
type: "text",
|
||||
name : "precio_min",
|
||||
class :"autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "precio_max"
|
||||
name: "precio_max",
|
||||
attr: {
|
||||
type: "text",
|
||||
name : "precio_max",
|
||||
class :"autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "precio_adicional",
|
||||
def: 0
|
||||
def: 0,
|
||||
attr: {
|
||||
type: "text",
|
||||
name : "precio_adicional",
|
||||
class :"autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "margen"
|
||||
name: "margen",
|
||||
attr: {
|
||||
type: "text",
|
||||
name : "margen",
|
||||
class :"autonumeric"
|
||||
}
|
||||
}, {
|
||||
"name": "tarifa_envio_id",
|
||||
"type": "hidden"
|
||||
@ -370,7 +435,37 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
|
||||
},
|
||||
]
|
||||
} );
|
||||
editor2.on('open', (event) => {
|
||||
$("input.autonumeric").each(function () {
|
||||
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
|
||||
if (autoNumericInstance) {
|
||||
autoNumericInstance.remove()
|
||||
|
||||
}
|
||||
new AutoNumeric(this, {
|
||||
decimalCharacter: ",",
|
||||
digitGroupSeparator: ".",
|
||||
allowDecimalPadding : 'floats',
|
||||
decimalPlaces: 2,
|
||||
unformatOnSubmit: true,
|
||||
});
|
||||
})
|
||||
})
|
||||
editor2.on('preSubmit', (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
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
// Generación de la lista de proveedores (id, nombre)
|
||||
const suppliersList = <?php echo json_encode($proveedores); ?>;
|
||||
editor2.field( 'proveedor_id' ).update( suppliersList );
|
||||
@ -455,12 +550,12 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
|
||||
return '<?= lang('TarifasEnviosPrecios.palets') ?>';
|
||||
}
|
||||
},
|
||||
{ 'data': 'peso_min' },
|
||||
{ 'data': 'peso_max' },
|
||||
{ 'data': 'precio_min' },
|
||||
{ 'data': 'precio_max' },
|
||||
{ 'data': 'precio_adicional' },
|
||||
{ 'data': 'margen' },
|
||||
{ 'data': 'peso_min',render : (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'peso_max',render : (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'precio_min',render : (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'precio_max',render : (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'precio_adicional',render : (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'margen',render : (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{
|
||||
data: actionBtns,
|
||||
className: 'row-edit dt-center'
|
||||
|
||||
Reference in New Issue
Block a user