mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
add autonumeric to number cells of datatables and editorDatatable
This commit is contained in:
@ -141,7 +141,11 @@ var editor_lineas = new $.fn.dataTable.Editor( {
|
|||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "cantidad",
|
name: "cantidad",
|
||||||
|
attr: {
|
||||||
|
type: "text",
|
||||||
|
name : "cantidad",
|
||||||
|
class :"autonumeric"
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
name: "descripcion",
|
name: "descripcion",
|
||||||
type: "textarea",
|
type: "textarea",
|
||||||
@ -152,10 +156,18 @@ var editor_lineas = new $.fn.dataTable.Editor( {
|
|||||||
}, {
|
}, {
|
||||||
name: "precio_unidad",
|
name: "precio_unidad",
|
||||||
attr: {
|
attr: {
|
||||||
|
type: "text",
|
||||||
|
name : "precio_unidad",
|
||||||
|
class :"autonumeric",
|
||||||
style: "min-width: 65px;"
|
style: "min-width: 65px;"
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
name: "iva",
|
name: "iva",
|
||||||
|
attr: {
|
||||||
|
type: "text",
|
||||||
|
name : "iva",
|
||||||
|
class :"autonumeric"
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
name: "pedido_linea_impresion_id",
|
name: "pedido_linea_impresion_id",
|
||||||
type: "hidden"
|
type: "hidden"
|
||||||
@ -174,7 +186,37 @@ var editor_lineas = new $.fn.dataTable.Editor( {
|
|||||||
|
|
||||||
|
|
||||||
var old_cantidad = 0;
|
var old_cantidad = 0;
|
||||||
|
editor_lineas.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_lineas.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_lineas.on( 'preEdit', function ( e, json, data, id ) {
|
editor_lineas.on( 'preEdit', function ( e, json, data, id ) {
|
||||||
|
|
||||||
old_cantidad = data.cantidad;
|
old_cantidad = data.cantidad;
|
||||||
@ -239,7 +281,7 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
|
|||||||
{data: "pedido_linea_impresion_id"},
|
{data: "pedido_linea_impresion_id"},
|
||||||
{data: "pedido_maquetacion_id"},
|
{data: "pedido_maquetacion_id"},
|
||||||
{data: "pedido_id"},
|
{data: "pedido_id"},
|
||||||
{data: "cantidad"},
|
{data: "cantidad",render : (d) => `<span class="autonumeric">${d}</span>`},
|
||||||
{
|
{
|
||||||
data: "descripcion",
|
data: "descripcion",
|
||||||
render: function (data, type, row, meta) {
|
render: function (data, type, row, meta) {
|
||||||
@ -324,11 +366,11 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{data: "precio_unidad"},
|
{data: "precio_unidad",render : (d) => `<span class="autonumeric">${d}</span>`},
|
||||||
{data: "iva"},
|
{data: "iva",render : (d) => `<span class="autonumeric">${d}</span>`},
|
||||||
{data: "base"},
|
{data: "base",render : (d) => `<span class="autonumeric">${d}</span>`},
|
||||||
{data: "total_iva"},
|
{data: "total_iva",render : (d) => `<span class="autonumeric">${d}</span>`},
|
||||||
{data: "total"},
|
{data: "total",render : (d) => `<span class="autonumeric">${d}</span>`},
|
||||||
],
|
],
|
||||||
order: [[1, "asc"]],
|
order: [[1, "asc"]],
|
||||||
dom: 't',
|
dom: 't',
|
||||||
|
|||||||
@ -160,9 +160,9 @@
|
|||||||
{ 'data': 'numero' },
|
{ 'data': 'numero' },
|
||||||
{ 'data': 'fecha_factura_at' },
|
{ 'data': 'fecha_factura_at' },
|
||||||
{ 'data': 'cliente' },
|
{ 'data': 'cliente' },
|
||||||
{ 'data': 'base' },
|
{ 'data': 'base' ,render : (d) => `<span class="autonumeric">${d}</span>`},
|
||||||
{ 'data': 'total' },
|
{ 'data': 'total',render : (d) => `<span class="autonumeric">${d}</span>`},
|
||||||
{ 'data': 'pendiente' },
|
{ 'data': 'pendiente',render : (d) => `<span class="autonumeric">${d}</span>` },
|
||||||
{ 'data': 'creditoAsegurado' ,
|
{ 'data': 'creditoAsegurado' ,
|
||||||
render: function(data, type, row, meta) {
|
render: function(data, type, row, meta) {
|
||||||
switch(data){
|
switch(data){
|
||||||
|
|||||||
Reference in New Issue
Block a user