42 } |
42 } |
43 |
43 |
44 |
44 |
45 $(document).ready(function () { |
45 $(document).ready(function () { |
46 |
46 |
47 var steprow = 0; |
|
48 var stepData = {}; |
|
49 var dataRecord = {}; |
|
50 var url = 'includes/db_profile_mash.php'; |
|
51 |
|
52 // tooltips |
47 // tooltips |
53 $("#name").jqxTooltip({ content: 'De naam voor dit maisch profiel.' }); |
48 $("#name").jqxTooltip({ content: 'De naam voor dit maisch profiel.' }); |
54 $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit maisch profiel.' }); |
49 $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit maisch profiel.' }); |
55 // prepare the data |
50 |
56 var source = { |
51 var steprow = 0, |
|
52 stepData = {}, |
|
53 dataRecord = {}, |
|
54 url = 'includes/db_profile_mash.php', |
|
55 source = { |
57 datatype: 'json', |
56 datatype: 'json', |
58 cache: false, |
57 cache: false, |
59 datafields: [ |
58 datafields: [ |
60 { name: 'record', type: 'number' }, |
59 { name: 'record', type: 'number' }, |
61 { name: 'name', type: 'string' }, |
60 { name: 'name', type: 'string' }, |
120 commit(false); |
119 commit(false); |
121 console.log('mash updaterow ' + textStatus); |
120 console.log('mash updaterow ' + textStatus); |
122 } |
121 } |
123 }); |
122 }); |
124 } |
123 } |
125 }; |
124 }, |
126 // Initialize the input fields. |
125 dataAdapter = new $.jqx.dataAdapter(source), |
127 $("#m_step_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
126 editrow = -1, |
128 $("#m_step_type").jqxDropDownList({ |
|
129 theme: theme, |
|
130 source: MashStepTypeAdapter, |
|
131 valueMember: 'id', |
|
132 displayMember: 'nl', |
|
133 width: 180, |
|
134 height: 23, |
|
135 autoDropDownHeight: true |
|
136 }); |
|
137 $("#m_step_temp").jqxNumberInput( Spin1dec ); |
|
138 $("#m_step_temp").jqxNumberInput({ Min: 30, Max: 80 }); |
|
139 $("#m_end_temp").jqxNumberInput( Spin1dec ); |
|
140 $("#m_end_temp").jqxNumberInput({ Min: 30, Max: 80 }); |
|
141 $("#m_step_time").jqxNumberInput( PosInt ); |
|
142 $("#m_step_time").jqxNumberInput({ Min: 1, Max: 120 }); |
|
143 $("#m_ramp_time").jqxNumberInput( PosInt ); |
|
144 $("#m_ramp_time").jqxNumberInput({ Min: 1, Max: 30 }); |
|
145 |
|
146 var dataAdapter = new $.jqx.dataAdapter(source), |
|
147 editrow = -1; |
|
148 |
127 |
149 // Inline steps editor |
128 // Inline steps editor |
150 var editsteps = function (data) { |
129 editsteps = function (data) { |
151 var generaterow = function () { |
130 var generaterow = function () { |
152 var row = {}; |
131 var row = {}; |
153 row['step_name'] = "Stap 1"; |
132 row['step_name'] = "Stap 1"; |
154 row['step_type'] = 0; |
133 row['step_type'] = 0; |
155 row['step_temp'] = 62.0; |
134 row['step_temp'] = 62.0; |
156 row['step_time'] = 20.0; |
135 row['step_time'] = 20.0; |
157 row['ramp_time'] = 1.0; |
136 row['ramp_time'] = 1.0; |
158 row['end_temp'] = 62.0; |
137 row['end_temp'] = 62.0; |
159 return row; |
138 return row; |
160 } |
139 }, |
161 var stepSource = { |
140 stepSource = { |
162 localdata: data.steps, |
141 localdata: data.steps, |
163 datatype: "local", |
142 datatype: "local", |
164 datafields: [ |
143 datafields: [ |
165 { name: 'step_name', type: 'string' }, |
144 { name: 'step_name', type: 'string' }, |
166 { name: 'step_type', type: 'int' }, |
145 { name: 'step_type', type: 'int' }, |
196 var datarow = generaterow(); |
176 var datarow = generaterow(); |
197 $("#grid").jqxGrid('addrow', null, datarow); |
177 $("#grid").jqxGrid('addrow', null, datarow); |
198 }); |
178 }); |
199 // delete row. |
179 // delete row. |
200 $("#deleterowbutton").on('click', function () { |
180 $("#deleterowbutton").on('click', function () { |
201 var selectedrowindex = $("#grid").jqxGrid('getselectedrowindex'); |
181 var rowscount, id, selectedrowindex = $("#grid").jqxGrid('getselectedrowindex'); |
202 var rowscount = $("#grid").jqxGrid('getdatainformation').rowscount; |
182 rowscount = $("#grid").jqxGrid('getdatainformation').rowscount; |
203 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
183 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
204 var id = $("#grid").jqxGrid('getrowid', selectedrowindex); |
184 id = $("#grid").jqxGrid('getrowid', selectedrowindex); |
205 $("#grid").jqxGrid('deleterow', id); |
185 $("#grid").jqxGrid('deleterow', id); |
206 } |
186 } |
207 }); |
187 }); |
208 }, |
188 }, |
209 columns: [ |
189 columns: [ |
215 }, |
195 }, |
216 { text: 'Begin °C', datafield: 'step_temp', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
196 { text: 'Begin °C', datafield: 'step_temp', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
217 { text: 'Eind °C', datafield: 'end_temp', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
197 { text: 'Eind °C', datafield: 'end_temp', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
218 { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, |
198 { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, |
219 { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, |
199 { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, |
220 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { |
200 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', |
221 return "Wijzig"; |
201 cellsrenderer: function () { |
|
202 return "Wijzig"; |
222 }, buttonclick: function (row) { |
203 }, buttonclick: function (row) { |
223 steprow = row; |
204 steprow = row; |
224 stepData = $("#grid").jqxGrid('getrowdata', steprow); |
205 stepData = $("#grid").jqxGrid('getrowdata', steprow); |
225 $("#m_step_name").val(stepData.step_name); |
206 $("#m_step_name").val(stepData.step_name); |
226 $("#m_step_type").val(stepData.step_type); |
207 $("#m_step_type").val(stepData.step_type); |
234 } |
215 } |
235 ] |
216 ] |
236 }); |
217 }); |
237 }; |
218 }; |
238 |
219 |
|
220 // Initialize the input fields. |
|
221 $("#m_step_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
|
222 $("#m_step_type").jqxDropDownList({ |
|
223 theme: theme, |
|
224 source: MashStepTypeAdapter, |
|
225 valueMember: 'id', |
|
226 displayMember: 'nl', |
|
227 width: 180, |
|
228 height: 23, |
|
229 autoDropDownHeight: true |
|
230 }); |
|
231 $("#m_step_temp").jqxNumberInput( Spin1dec ); |
|
232 $("#m_step_temp").jqxNumberInput({ Min: 30, Max: 80 }); |
|
233 $("#m_end_temp").jqxNumberInput( Spin1dec ); |
|
234 $("#m_end_temp").jqxNumberInput({ Min: 30, Max: 80 }); |
|
235 $("#m_step_time").jqxNumberInput( PosInt ); |
|
236 $("#m_step_time").jqxNumberInput({ Min: 1, Max: 120 }); |
|
237 $("#m_ramp_time").jqxNumberInput( PosInt ); |
|
238 $("#m_ramp_time").jqxNumberInput({ Min: 1, Max: 30 }); |
|
239 |
239 // initialize the input fields. |
240 // initialize the input fields. |
240 $("#name").jqxInput({ theme: theme, width: 480, height: 23 }); |
241 $("#name").jqxInput({ theme: theme, width: 480, height: 23 }); |
241 $("#notes").jqxInput({ theme: theme, width: 800, height: 100 }); |
242 $("#notes").jqxInput({ theme: theme, width: 800, height: 100 }); |
242 // initialize jqxGrid |
243 // initialize jqxGrid |
243 $("#jqxgrid").jqxGrid({ |
244 $("#jqxgrid").jqxGrid({ |
245 height: 630, |
246 height: 630, |
246 source: dataAdapter, |
247 source: dataAdapter, |
247 theme: theme, |
248 theme: theme, |
248 showstatusbar: true, |
249 showstatusbar: true, |
249 renderstatusbar: function (statusbar) { |
250 renderstatusbar: function (statusbar) { |
250 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
251 var addButton, container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
251 var addButton = $("<div style='float: right; margin-right: 15px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Add</span></div>"); |
252 addButton = $("<div style='float: right; margin-right: 15px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Add</span></div>"); |
252 container.append(addButton); |
253 container.append(addButton); |
253 statusbar.append(container); |
254 statusbar.append(container); |
254 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
255 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
255 // add new row. |
256 // add new row. |
256 addButton.click(function (event) { |
257 addButton.click(function (event) { |
264 filterable: true, |
265 filterable: true, |
265 filtermode: 'excel', |
266 filtermode: 'excel', |
266 columns: [ |
267 columns: [ |
267 { text: 'Maish schema', datafield: 'name', width: 250 }, |
268 { text: 'Maish schema', datafield: 'name', width: 250 }, |
268 { text: 'Opmerkingen', datafield: 'notes' }, |
269 { text: 'Opmerkingen', datafield: 'notes' }, |
269 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () { |
270 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', |
270 return "Wijzig"; |
271 cellsrenderer: function () { |
|
272 return "Wijzig"; |
271 }, buttonclick: function (row) { |
273 }, buttonclick: function (row) { |
272 editrow = row; |
274 editrow = row; |
273 // get the clicked row's data and initialize the input fields. |
275 // get the clicked row's data and initialize the input fields. |
274 dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); |
276 dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); |
275 $("#name").val(dataRecord.name); |
277 $("#name").val(dataRecord.name); |
334 $("#popupWindow").jqxWindow('hide'); |
336 $("#popupWindow").jqxWindow('hide'); |
335 }); |
337 }); |
336 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme }); |
338 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme }); |
337 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); |
339 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); |
338 $("#Save").click(function () { |
340 $("#Save").click(function () { |
339 var steprows = $('#grid').jqxGrid('getrows'); |
341 var steprows = $('#grid').jqxGrid('getrows'), |
340 var rowID = -1; |
342 rowID = -1, |
|
343 row; |
341 if (editrow >= 0) { |
344 if (editrow >= 0) { |
342 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
345 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
343 } |
346 } |
344 var row = { |
347 row = { |
345 record: rowID, |
348 record: rowID, |
346 name: $("#name").val(), |
349 name: $("#name").val(), |
347 notes: $("#notes").val(), |
350 notes: $("#notes").val(), |
348 steps: steprows |
351 steps: steprows |
349 }; |
352 }; |