1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| {
"DT_RowId": "row_15",
"Étage": "2",
"Type - numéro": " T1 - 13",
"Superficie": "15.75",
"Terrasse": "",
"Mezzanine": "",
"Loyer": "475",
"Prix au m²": function(){return(this.Loyer / this.Superficie).toFixed(2)}
}
]
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
data: dataSet,
table: "#loyers",
fields: [ {
label: "Superficie :",
name: "Superficie"
}, {
label: "Terrasse :",
name: "Terrasse"
}, {
label: "Mezzanine :",
name: "Mezzanine",
}, {
label: "Loyer :",
name: "Loyer",
},
]
} );
$('#loyers').on( 'click', 'tbody td', function (e) {
var index = $(this).index();
if ( index === 2 || index === 3 || index === 4) {
editor.bubble( this, {
message: 'Entrez un nombre décimal séparé par un point.',
submit: 'allIfChanged'
} );
}
else if ( index === 5 ) {
editor.bubble( this ), {
submit: 'allIfChanged'
}
}
} );
$('#loyers').DataTable( {
dom: '"Brt"',
data: dataSet,
searching: false,
paging: false,
info: false,
columns: [
{ data: "Étage" },
{ data: "Type - numéro" },
{ data: "Superficie",render: $.fn.dataTable.render.number(' ', ',', 2, '', ' m²') },
{ data: "Terrasse",render: $.fn.dataTable.render.number(' ', ',', 2, '', ' m²')},
{ data: "Mezzanine",render: $.fn.dataTable.render.number(' ', ',', 2, '', ' m²')},
{ data: "Loyer",render: $.fn.dataTable.render.number(' ', ',', 0, '', ' ')},
{ data: "Prix au m²",render: $.fn.dataTable.render.number(' ', ',', 2, '', ' ')},
], |
Partager