Apply mask to cell values
Apply mask to cell values
Hi,
Let me say I found jQuery and DataTables a few days ago and i'm surprised with all this, soo i'm simply a noob. But untill now... let me say this is scripting at state of art.
I need to apply a javascript function to mascarade each cell in a coll, let say I want to auto change the value from '1000' to '$1.000' or '1,000 €'.
This function is done and working in javascript what I don't know is how to use it in DataTables.
My Table is:
[code]
$(document).ready(function() {
var oTable = $('#table_6_2').dataTable( {
"bProcessing": true,
"sAjaxSource": 'modules.php?name=teste5&opt=table_6_2®='+base64_encode(array2string(window.registos)),
"bServerSide": true,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"bAutoWidth": true,
"aoColumns": [
{ "mDataProp": "vendas_facturas_linhas[sdo]" },
{ "mDataProp": "vendas_facturas_linhas[linha]" },
{ "mDataProp": "vendas_facturas_linhas[factura]" },
{ "mDataProp": "vendas_facturas_linhas[mercadoria]" },
{ "mDataProp": "vendas_facturas_linhas[designacao]" },
{ "mDataProp": "vendas_facturas_linhas[quantidade]" },
{ "mDataProp": "mercadorias_unidades_venda[designacao_abrev]" },
{ "mDataProp": "vendas_facturas_linhas[preco_venda]" },
{ "mDataProp": "vendas_facturas_linhas[taxa_desconto_comercial]" },
{ "mDataProp": "vendas_facturas_linhas[tipo_iva_venda]" },
{ "mDataProp": "vendas_facturas_linhas[taxa_iva]" },
{ "mDataProp": "vendas_facturas_linhas[total_iva]" },
{ "mDataProp": "vendas_facturas_linhas[total_bruto]" }
],
"fnDrawCallback": function() {
?????????????;
}
} );
} );
[/code]
If you can help please do. Much apreciated.
Let me say I found jQuery and DataTables a few days ago and i'm surprised with all this, soo i'm simply a noob. But untill now... let me say this is scripting at state of art.
I need to apply a javascript function to mascarade each cell in a coll, let say I want to auto change the value from '1000' to '$1.000' or '1,000 €'.
This function is done and working in javascript what I don't know is how to use it in DataTables.
My Table is:
[code]
$(document).ready(function() {
var oTable = $('#table_6_2').dataTable( {
"bProcessing": true,
"sAjaxSource": 'modules.php?name=teste5&opt=table_6_2®='+base64_encode(array2string(window.registos)),
"bServerSide": true,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"bAutoWidth": true,
"aoColumns": [
{ "mDataProp": "vendas_facturas_linhas[sdo]" },
{ "mDataProp": "vendas_facturas_linhas[linha]" },
{ "mDataProp": "vendas_facturas_linhas[factura]" },
{ "mDataProp": "vendas_facturas_linhas[mercadoria]" },
{ "mDataProp": "vendas_facturas_linhas[designacao]" },
{ "mDataProp": "vendas_facturas_linhas[quantidade]" },
{ "mDataProp": "mercadorias_unidades_venda[designacao_abrev]" },
{ "mDataProp": "vendas_facturas_linhas[preco_venda]" },
{ "mDataProp": "vendas_facturas_linhas[taxa_desconto_comercial]" },
{ "mDataProp": "vendas_facturas_linhas[tipo_iva_venda]" },
{ "mDataProp": "vendas_facturas_linhas[taxa_iva]" },
{ "mDataProp": "vendas_facturas_linhas[total_iva]" },
{ "mDataProp": "vendas_facturas_linhas[total_bruto]" }
],
"fnDrawCallback": function() {
?????????????;
}
} );
} );
[/code]
If you can help please do. Much apreciated.
This discussion has been closed.
Replies
[quote]
var oTable = $('#table_6_2').dataTable( {
"bProcessing": false,
"sAjaxSource": 'modules.php?name=teste5&opt=table_6_2®='+base64_encode(a2s(window.registos)),
"bServerSide": true,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"bAutoWidth": true,
"aoColumns": [
{ "mDataProp": "vendas_facturas_linhas[sdo]" },
{ "mDataProp": "vendas_facturas_linhas[linha]" },
{ "mDataProp": "vendas_facturas_linhas[factura]" },
{ "mDataProp": "vendas_facturas_linhas[mercadoria]" },
{ "mDataProp": "vendas_facturas_linhas[designacao]" },
{ "mDataProp": "vendas_facturas_linhas[quantidade]" },
{ "mDataProp": "mercadorias_unidades_venda[designacao_abrev]" },
{ "mDataProp": "vendas_facturas_linhas[preco_venda]" },
{ "mDataProp": "vendas_facturas_linhas[taxa_desconto_comercial]" },
{ "mDataProp": "vendas_facturas_linhas[tipo_iva_venda]" },
{ "mDataProp": "vendas_facturas_linhas[taxa_iva]" },
{ "mDataProp": "vendas_facturas_linhas[total_iva]" },
{ "mDataProp": "vendas_facturas_linhas[total_bruto]" }
],
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
$('td:eq(5)', nRow).html( DECIMALMask('', '-nnn,nnN.nnn', aData["vendas_facturas_linhas[quantidade]"]) );
$('td:eq(7)', nRow).html( DECIMALMask('', 'nn,nnn,nnN.NNn €', aData["vendas_facturas_linhas[preco_venda]"]) );
$('td:eq(8)', nRow).html( DECIMALMask('','nnN.nn%', aData["vendas_facturas_linhas[taxa_desconto_comercial]"]) );
$('td:eq(10)', nRow).html( DECIMALMask('','nN.n%', aData["vendas_facturas_linhas[taxa_iva]"]) );
$('td:eq(11)', nRow).html( DECIMALMask('','nn,nnn,nnN.NN €', aData["vendas_facturas_linhas[total_iva]"]) );
$('td:eq(12)', nRow).html( DECIMALMask('','nn,nnn,nnN.NN €', aData["vendas_facturas_linhas[total_bruto]"]) );
return nRow;
}
} );
[/quote]
Is this right?
Allan
Your post was very helpfull. I need to use original values for cells, the mask is only to show data, not to use it.