Edito: modify field calculated
Edito: modify field calculated
david.papini
Posts: 21Questions: 5Answers: 0
I've a datatable with same editable column, All calumns are bind with datasource
var editor;
function jsFunctionCalcolaQtaCo(data, type, full, meta) {
data = full.Qtagg / full.ConfezioniXCollo;
editor.field(meta.settings.aoColumns[meta.col].mData).val(data);
editor.submit();
return Math.round(data);
}
function jsFunctionCalcolaQtaKg(data, type, full, meta) {
data = full.Qtagg * full.PesoXPezzo;
return Math.round(data);
}
$(document).ready(function () {
editor = new $.fn.dataTable.Editor({
table: '#tableOrdineFornitoreEdit',
idSrc: 'CdArticolo',
fields: [
{
"name": "CdArticolo",
"label": "Cd. Articolo",
},
{
"name": "DsArticolo",
"label": "Descrizione",
},
{
"name": "CdStato",
"label": "Stato",
},
{
"name": "CdUm",
"label": "U.M.",
},
{
"name": "Qtagg",
"label": "Qta",
},
{
"name": "QtaCo",
"label": "QtaCo",
},
{
"name": "QtaKg",
"label": "QtaKg",
},
{
"name": "ImNetto",
"label": "Prezzo",
},
{
"name": "IsOrdinabile",
"label": "Ordinabile",
},
],
formOptions: {
inline: { onBlur: true }
}
});
//datatable definition
$('#tableOrdineFornitoreEdit').dataTable({
dom: 'Bfrtip',
ajax: {
type: "POST",
data: function (d) {
var _data = { 'StringSearch': JSON.stringify({ pCdFornitore: 9110 }) };
return _data;
},
url: App.getGlobalWcfErgonPath() + "GetPropostatOrdineFornitore",
dataType: "jsonp",
contentType: "application/json; charset=utf-8",
dataSrc: function (json) {
var parseJson = JSON.parse(json.Data);
if ('data' in parseJson && parseJson.data.length == 0) return;
var f = "loadOrdineFornitore" + "(json.Data);"
return eval(f);
}
},
"filter": true,"info": false,"ordering": true,"processing": true,"retrieve": true,
order: [[0, 'asc']],
responsive: true,
language: {
"url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Italian.json"
},
columns: [
{
"data": "CdArticolo",
"type": "text",
"title": "Cd. Articolo",
"className": "dt-center",
"orderable": true,
"visible": true,
},
{
"data": "DsArticolo",
"type": "text",
"title": "Descrizione",
"className": "dt-left",
"orderable": true,
"visible": true,
"render": function(data,type, full, meta) {
return jsFunctionDescrizione(data, type, full, meta); },
},
{
"data": "CdStato",
"type": "text",
"title": "Stato",
"className": "dt-left",
"orderable": false,
"visible": true,
},
{
"data": "CdUm",
"type": "text",
"title": "U.M.",
"className": "dt-left",
"orderable": false,
"visible": true,
},
{
"data": "Qtagg",
"type": "text",
"title": "Qta",
"className": "dt-right editable",
"orderable": false,
"visible": true,
},
{
"data": "QtaCo",
"type": "text",
"title": "QtaCo",
"className": "dt-right editable ",
"orderable": false,
"visible": true,
"render": function(data,type, full, meta) {
return jsFunctionCalcolaQtaCo(data, type, full, meta); },
},
{ "data": "QtaKg",
"type": "text",
"title": "QtaKg",
"className": "dt-right editable ",
"orderable": false,
"visible": true,
"render": function(data,type, full, meta) {
return jsFunctionCalcolaQtaKg(data, type, full, meta); },
},
{ "data": "ImNetto",
"type": "text",
"title": "Prezzo",
"className": "dt-right",
"orderable": true,
"visible": true,
"render": function(data,type, full, meta) {
return jsFunctionImportoNetto(data, type, full, meta); },
},
{ "data": null,
"defaultContent": '',
"title": "Importo",
"className": "dt-right",
"orderable": false,
"visible": true,
"render": function(data,type, full, meta) {
return jsFunctionCalcolaImporto(data, type, full, meta); },
},
{ "data": "IsOrdinabile",
"type": "text",
"title": "Ordinabile",
"className": "dt-right",
"orderable": false,
"visible": false,
},
],
select: true,
keys: {
columns: '.editable',
keys: [9],
editor: editor,
editOnFocus: true
},
initComplete: function (settings) {
var f = "JsAddToHeader" + "(settings);"
eval(f);
},
});
});
i try to change the value of editor, but not working and when i go to modify the value i've the old value and not the new. the new value is only on datatable, i saw the new display, but i can't modify?
Someone can help me?
This discussion has been closed.
Answers
I'm not quite clear what the problem is. Are you saying that you edit a field in the Editor form, and this is then updated in the table. But when you edit again, the Editor form is showing the previous value?
Are you able to link to your page so we can see it in action?
Colin
thank you i found the solution,. I'ved three column depend one to other
i'user intisubmit event