www/js/rec_edit.js

changeset 131
71f1ca48c551
parent 130
601920b902e5
child 132
aaefac2d08a3
--- a/www/js/rec_edit.js	Sat Dec 08 15:20:03 2018 +0100
+++ b/www/js/rec_edit.js	Sat Dec 08 17:11:38 2018 +0100
@@ -785,11 +785,11 @@
                                 { text: 'Hop', editable: false, datafield: 'h_name' },
                                 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' },
 				{ text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' },
-                                { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
-                                { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3',
+                                { text: 'Alpha', editable: false, datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
+                                { text: 'Gewicht Kg', datafield: 'h_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f4',
                                   columntype: 'numberinput',
 				  initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
-					editor.jqxNumberInput({ decimalDigits: 3, min: 0, spinButtons: false });
+					editor.jqxNumberInput({ decimalDigits: 4, min: 0, spinButtons: false });
 				  },
                                   validation: function (cell, value) {
                                         if (value < 0 || value > 100000000000 ) {
@@ -802,15 +802,25 @@
 				  createeditor: function (row, column, editor) {
 					  var srcUse = [ "Boil", "Dry Hop", "Mash", "First Wort", "Aroma" ];
 					  editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUse });
+				  },
+				  cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
+					if ((newvalue == "Mash") || (newvalue == "First Wort")) {
+						$("#hopGrid").jqxGrid('setcellvalue', row, "h_time", parseFloat($("#boil_time").jqxNumberInput('decimal')));
+					} else if (newvalue == "Aroma") {
+						$("#hopGrid").jqxGrid('setcellvalue', row, "h_time", 0);
+					}
 				  }
-				  // cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
-				  // do iets met de h_time.
 				},
 				{ text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0',
 				  columntype: 'numberinput',
 				  initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
 					editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0 });
 				  },
+				  cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
+					var use = $("#hopGrid").jqxGrid('getcellvalue', row, "h_useat");
+					if (use != "Boil")
+						return oldvalue;
+				  },
 				  validation: function (cell, value) {
 					var high = parseFloat($("#boil_time").jqxNumberInput('decimal'));
 				  	if (value < 0 || value > high ) {
@@ -837,9 +847,12 @@
 				}
                         ]
                 });
-//		$("#hopGrid").on('cellendedit', function (event) {
+		$("#hopGrid").on('cellendedit', function (event) {
+			var args = event.args;
+			console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
+			$("#hopGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
 //			//$('#hopGrid').jqxGrid('sortby', 'f_amount', 'desc');
-//		});
+		});
         };
 
 	// Inline miscs editor

mercurial