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:
@ -122,18 +122,33 @@
|
||||
class :"autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "precio_max"
|
||||
name: "precio_max",
|
||||
attr: {
|
||||
type: "text",
|
||||
name : "tirada_min",
|
||||
class :"autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "tirada_max",
|
||||
attr: {
|
||||
type: "text",
|
||||
name : "tirada_max",
|
||||
class :"autonumeric"
|
||||
type: "text",
|
||||
name : "tirada_max",
|
||||
class :"autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "precio_min"
|
||||
name: "precio_min",
|
||||
attr: {
|
||||
type: "text",
|
||||
name : "tirada_min",
|
||||
class :"autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "margen"
|
||||
name: "margen",
|
||||
attr: {
|
||||
type: "text",
|
||||
name : "tirada_min",
|
||||
class :"autonumeric"
|
||||
}
|
||||
}, {
|
||||
"name": "tarifa_manipulado_id",
|
||||
"type": "hidden"
|
||||
@ -147,35 +162,38 @@
|
||||
]
|
||||
} );
|
||||
|
||||
editor.on('open',(event)=>{
|
||||
$("input.autonumeric").each(function () {
|
||||
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
|
||||
if(autoNumericInstance){
|
||||
autoNumericInstance.remove()
|
||||
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,
|
||||
});
|
||||
})
|
||||
}
|
||||
new AutoNumeric(this, {
|
||||
decimalCharacter: ",",
|
||||
digitGroupSeparator: ".",
|
||||
allowDecimalPadding : 'floats',
|
||||
decimalPlaces: 2,
|
||||
unformatOnSubmit: true,
|
||||
});
|
||||
})
|
||||
editor.on( 'preSubmit', function ( e, d, type ) {
|
||||
})
|
||||
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)
|
||||
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'){
|
||||
d.data[0]['tarifa_manipulado_id'] = id;
|
||||
@ -224,10 +242,10 @@
|
||||
}),
|
||||
columns: [
|
||||
{ 'data': 'tirada_min',render : (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'precio_max', },
|
||||
{ 'data': 'precio_max',render : (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'tirada_max',render : (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'precio_min' },
|
||||
{ 'data': 'margen' },
|
||||
{ 'data': 'precio_min',render : (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'margen',render : (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{
|
||||
data: actionBtns,
|
||||
className: 'row-edit dt-center'
|
||||
@ -284,14 +302,7 @@
|
||||
);
|
||||
} );
|
||||
|
||||
theTable.on('draw',() => {
|
||||
AutoNumeric.multiple("span.autonumeric", {
|
||||
digitGroupSeparator: ".",
|
||||
decimalCharacter: ",",
|
||||
decimalPlaces : 0,
|
||||
unformatOnSubmit: true
|
||||
});
|
||||
})
|
||||
|
||||
// Delete row
|
||||
$('#tableOfTarifamanipuladolineas').on( 'click', 'tbody span.remove', function (e) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user