diff -r 8c4f08445624 -r af28ebe4a779 www/js/profile_mash.js --- a/www/js/profile_mash.js Fri Sep 13 23:02:38 2019 +0200 +++ b/www/js/profile_mash.js Sat Sep 14 19:04:29 2019 +0200 @@ -44,16 +44,15 @@ $(document).ready(function () { - var steprow = 0; - var stepData = {}; - var dataRecord = {}; - var url = 'includes/db_profile_mash.php'; - // tooltips $("#name").jqxTooltip({ content: 'De naam voor dit maisch profiel.' }); $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit maisch profiel.' }); - // prepare the data - var source = { + + var steprow = 0, + stepData = {}, + dataRecord = {}, + url = 'includes/db_profile_mash.php', + source = { datatype: 'json', cache: false, datafields: [ @@ -122,32 +121,12 @@ } }); } - }; - // Initialize the input fields. - $("#m_step_name").jqxInput({ theme: theme, width: 320, height: 23 }); - $("#m_step_type").jqxDropDownList({ - theme: theme, - source: MashStepTypeAdapter, - valueMember: 'id', - displayMember: 'nl', - width: 180, - height: 23, - autoDropDownHeight: true - }); - $("#m_step_temp").jqxNumberInput( Spin1dec ); - $("#m_step_temp").jqxNumberInput({ Min: 30, Max: 80 }); - $("#m_end_temp").jqxNumberInput( Spin1dec ); - $("#m_end_temp").jqxNumberInput({ Min: 30, Max: 80 }); - $("#m_step_time").jqxNumberInput( PosInt ); - $("#m_step_time").jqxNumberInput({ Min: 1, Max: 120 }); - $("#m_ramp_time").jqxNumberInput( PosInt ); - $("#m_ramp_time").jqxNumberInput({ Min: 1, Max: 30 }); - - var dataAdapter = new $.jqx.dataAdapter(source), - editrow = -1; + }, + dataAdapter = new $.jqx.dataAdapter(source), + editrow = -1, // Inline steps editor - var editsteps = function (data) { + editsteps = function (data) { var generaterow = function () { var row = {}; row['step_name'] = "Stap 1"; @@ -157,8 +136,8 @@ row['ramp_time'] = 1.0; row['end_temp'] = 62.0; return row; - } - var stepSource = { + }, + stepSource = { localdata: data.steps, datatype: "local", datafields: [ @@ -175,8 +154,9 @@ deleterow: function (rowid, commit) { commit(true); } - }; - var stepAdapter = new $.jqx.dataAdapter(stepSource); + }, + stepAdapter = new $.jqx.dataAdapter(stepSource); + $("#grid").jqxGrid({ width: 1020, height: 330, @@ -198,10 +178,10 @@ }); // delete row. $("#deleterowbutton").on('click', function () { - var selectedrowindex = $("#grid").jqxGrid('getselectedrowindex'); - var rowscount = $("#grid").jqxGrid('getdatainformation').rowscount; + var rowscount, id, selectedrowindex = $("#grid").jqxGrid('getselectedrowindex'); + rowscount = $("#grid").jqxGrid('getdatainformation').rowscount; if (selectedrowindex >= 0 && selectedrowindex < rowscount) { - var id = $("#grid").jqxGrid('getrowid', selectedrowindex); + id = $("#grid").jqxGrid('getrowid', selectedrowindex); $("#grid").jqxGrid('deleterow', id); } }); @@ -217,8 +197,9 @@ { text: 'Eind °C', datafield: 'end_temp', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, - { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { - return "Wijzig"; + { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', + cellsrenderer: function () { + return "Wijzig"; }, buttonclick: function (row) { steprow = row; stepData = $("#grid").jqxGrid('getrowdata', steprow); @@ -236,6 +217,26 @@ }); }; + // Initialize the input fields. + $("#m_step_name").jqxInput({ theme: theme, width: 320, height: 23 }); + $("#m_step_type").jqxDropDownList({ + theme: theme, + source: MashStepTypeAdapter, + valueMember: 'id', + displayMember: 'nl', + width: 180, + height: 23, + autoDropDownHeight: true + }); + $("#m_step_temp").jqxNumberInput( Spin1dec ); + $("#m_step_temp").jqxNumberInput({ Min: 30, Max: 80 }); + $("#m_end_temp").jqxNumberInput( Spin1dec ); + $("#m_end_temp").jqxNumberInput({ Min: 30, Max: 80 }); + $("#m_step_time").jqxNumberInput( PosInt ); + $("#m_step_time").jqxNumberInput({ Min: 1, Max: 120 }); + $("#m_ramp_time").jqxNumberInput( PosInt ); + $("#m_ramp_time").jqxNumberInput({ Min: 1, Max: 30 }); + // initialize the input fields. $("#name").jqxInput({ theme: theme, width: 480, height: 23 }); $("#notes").jqxInput({ theme: theme, width: 800, height: 100 }); @@ -247,8 +248,8 @@ theme: theme, showstatusbar: true, renderstatusbar: function (statusbar) { - var container = $("
"); - var addButton = $("
Add
"); + var addButton, container = $("
"); + addButton = $("
Add
"); container.append(addButton); statusbar.append(container); addButton.jqxButton({ theme: theme, width: 90, height: 20 }); @@ -266,8 +267,9 @@ columns: [ { text: 'Maish schema', datafield: 'name', width: 250 }, { text: 'Opmerkingen', datafield: 'notes' }, - { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () { - return "Wijzig"; + { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', + cellsrenderer: function () { + return "Wijzig"; }, buttonclick: function (row) { editrow = row; // get the clicked row's data and initialize the input fields. @@ -336,12 +338,13 @@ $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme }); $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); $("#Save").click(function () { - var steprows = $('#grid').jqxGrid('getrows'); - var rowID = -1; + var steprows = $('#grid').jqxGrid('getrows'), + rowID = -1, + row; if (editrow >= 0) { rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); } - var row = { + row = { record: rowID, name: $("#name").val(), notes: $("#notes").val(),