www/js/profile_water.js

changeset 485
3cdfcdd71077
parent 286
124af734af68
child 494
af28ebe4a779
equal deleted inserted replaced
484:2083c274b283 485:3cdfcdd71077
42 } 42 }
43 43
44 44
45 $(document).ready(function () { 45 $(document).ready(function () {
46 46
47 var dataRecord = {};
48
49 var url = "includes/db_profile_water.php";
50 // tooltips 47 // tooltips
51 $("#name").jqxTooltip({ content: 'De unieke naam van dit water profiel.' }); 48 $("#name").jqxTooltip({ content: 'De unieke naam van dit water profiel.' });
52 $("#notes").jqxTooltip({ content: 'Extra opmerkingen over dit water.' }); 49 $("#notes").jqxTooltip({ content: 'Extra opmerkingen over dit water.' });
53 $("#calcium").jqxTooltip({ content: 'Calcium (Ca).' }); 50 $("#calcium").jqxTooltip({ content: 'Calcium (Ca).' });
54 $("#bicarbonate").jqxTooltip({ content: 'Bicarbonaat (HCO3). Berekend meteen de Totale alkaliteit.' }); 51 $("#bicarbonate").jqxTooltip({ content: 'Bicarbonaat (HCO3). Berekend meteen de Totale alkaliteit.' });
57 $("#sodium").jqxTooltip({ content: 'Natrium, oftewel keukenzout (Na). In berekeningen ook vaak als Sodium.' }); 54 $("#sodium").jqxTooltip({ content: 'Natrium, oftewel keukenzout (Na). In berekeningen ook vaak als Sodium.' });
58 $("#magnesium").jqxTooltip({ content: 'Magnesium (Mg).' }); 55 $("#magnesium").jqxTooltip({ content: 'Magnesium (Mg).' });
59 $("#ph").jqxTooltip({ content: 'De zuurgraad (pH).' }); 56 $("#ph").jqxTooltip({ content: 'De zuurgraad (pH).' });
60 $("#total_alkalinity").jqxTooltip({ content: 'Totale alkaliniteit. Berekend meteen de Bicarbonaat.' }); 57 $("#total_alkalinity").jqxTooltip({ content: 'Totale alkaliniteit. Berekend meteen de Bicarbonaat.' });
61 58
62 // prepare the data 59 var dataRecord = {},
63 var source = { 60 url = 'includes/db_profile_water.php',
61 source = {
64 datatype: "json", 62 datatype: "json",
65 cache: false, 63 cache: false,
66 datafields: [ 64 datafields: [
67 { name: 'record', type: 'number' }, 65 { name: 'record', type: 'number' },
68 { name: 'name', type: 'string' }, 66 { name: 'name', type: 'string' },
86 url: url, 84 url: url,
87 cache: false, 85 cache: false,
88 data: data, 86 data: data,
89 type: "POST", 87 type: "POST",
90 success: function (data, status, xhr) { 88 success: function (data, status, xhr) {
91 // delete command is executed.
92 commit(true); 89 commit(true);
90 location.reload( true );
93 }, 91 },
94 error: function (jqXHR, textStatus, errorThrown) { 92 error: function (jqXHR, textStatus, errorThrown) {
95 commit(false); 93 commit(false);
96 } 94 }
97 }); 95 });
104 cache: false, 102 cache: false,
105 data: data, 103 data: data,
106 type: "POST", 104 type: "POST",
107 success: function (data, status, xhr) { 105 success: function (data, status, xhr) {
108 commit(true); 106 commit(true);
107 location.reload( true );
109 }, 108 },
110 error: function(jqXHR, textStatus, errorThrown) { 109 error: function(jqXHR, textStatus, errorThrown) {
111 commit(false); 110 commit(false);
112 } 111 }
113 }); 112 });
119 url: url, 118 url: url,
120 cache: false, 119 cache: false,
121 data: data, 120 data: data,
122 type: "POST", 121 type: "POST",
123 success: function (data, status, xhr) { 122 success: function (data, status, xhr) {
124 // update command is executed.
125 commit(true); 123 commit(true);
124 location.reload( true );
126 }, 125 },
127 error: function(jqXHR, textStatus, errorThrown) { 126 error: function(jqXHR, textStatus, errorThrown) {
128 commit(false); 127 commit(false);
129 } 128 }
130 }); 129 });
140 $("#sodium").jqxNumberInput( Spin1dec ); 139 $("#sodium").jqxNumberInput( Spin1dec );
141 $("#magnesium").jqxNumberInput( Spin1dec ); 140 $("#magnesium").jqxNumberInput( Spin1dec );
142 $("#ph").jqxNumberInput( Spin2pH ); 141 $("#ph").jqxNumberInput( Spin2pH );
143 $("#total_alkalinity").jqxNumberInput( Spin1dec ); 142 $("#total_alkalinity").jqxNumberInput( Spin1dec );
144 143
145 var dataAdapter = new $.jqx.dataAdapter(source); 144 var dataAdapter = new $.jqx.dataAdapter(source),
146 var editrow = -1; 145 editrow = -1;
147 // initialize jqxGrid 146 // initialize jqxGrid
148 $("#jqxgrid").jqxGrid({ 147 $("#jqxgrid").jqxGrid({
149 width: 1280, 148 width: 1280,
150 height: 630, 149 height: 630,
151 source: dataAdapter, 150 source: dataAdapter,
191 }, buttonclick: function (row) { 190 }, buttonclick: function (row) {
192 // open the popup window when the user clicks a button. 191 // open the popup window when the user clicks a button.
193 editrow = row; 192 editrow = row;
194 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); 193 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } });
195 // get the clicked row's data and initialize the input fields. 194 // get the clicked row's data and initialize the input fields.
196 var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); 195 dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
197 $("#name").val(dataRecord.name); 196 $("#name").val(dataRecord.name);
198 $("#calcium").val(dataRecord.calcium); 197 $("#calcium").val(dataRecord.calcium);
199 $("#bicarbonate").val(dataRecord.bicarbonate); 198 $("#bicarbonate").val(dataRecord.bicarbonate);
200 $("#sulfate").val(dataRecord.sulfate); 199 $("#sulfate").val(dataRecord.sulfate);
201 $("#chloride").val(dataRecord.chloride); 200 $("#chloride").val(dataRecord.chloride);
271 $('#jqxgrid').jqxGrid('updaterow', rowID, row); 270 $('#jqxgrid').jqxGrid('updaterow', rowID, row);
272 } else { 271 } else {
273 $('#jqxgrid').jqxGrid('addrow', null, row); 272 $('#jqxgrid').jqxGrid('addrow', null, row);
274 } 273 }
275 $("#popupWindow").jqxWindow('hide'); 274 $("#popupWindow").jqxWindow('hide');
276 location.reload( true ); // reload ourself.
277 }); 275 });
278 createDelElements(); 276 createDelElements();
279 }); 277 });
280 278

mercurial