www/js/rec_edit.js

changeset 140
93c64d7ac79c
parent 139
eb1ac7487710
child 141
fe9e2a677611
equal deleted inserted replaced
139:eb1ac7487710 140:93c64d7ac79c
935 columns: [ 935 columns: [
936 { text: 'Hop', editable: false, datafield: 'h_name' }, 936 { text: 'Hop', editable: false, datafield: 'h_name' },
937 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, 937 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' },
938 { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, 938 { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' },
939 { text: 'Alpha', editable: false, datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, 939 { text: 'Alpha', editable: false, datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
940 { text: 'Gewicht Kg', datafield: 'h_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f4', 940 // Edit the amount in grams, shoukd be fine for batches < 10 hl.
941 { text: 'Gewicht gr', datafield: 'grams', width: 120, align: 'right', columntype: 'numberinput', cellsformat: 'f1',
942 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
943 var gram = rowdata.h_amount * 1000;
944 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(gram, "f1") + " gr</div>";
945 },
946 validation: function (cell, value) {
947 var maxhops = parseFloat($("#batch_size").jqxNumberInput('decimal')) * 200;
948 if (value < 0 || value > maxhops ) {
949 return { result: false, message: "Volume moet 0-"+maxhops+" zijn" };
950 }
951 return true;
952 }
953 },
954 /* { text: 'Gewicht Kg', datafield: 'h_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f4',
941 columntype: 'numberinput', 955 columntype: 'numberinput',
942 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { 956 initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
943 editor.jqxNumberInput({ decimalDigits: 4, min: 0, spinButtons: false }); 957 editor.jqxNumberInput({ decimalDigits: 4, min: 0, spinButtons: false });
944 }, 958 },
945 validation: function (cell, value) { 959 validation: function (cell, value) {
946 if (value < 0 || value > 100000000000 ) { 960 if (value < 0 || value > 100000000000 ) {
947 return { result: false, message: "Volume moet 0-~ zijn" }; 961 return { result: false, message: "Volume moet 0-~ zijn" };
948 } 962 }
949 return true; 963 return true;
950 } 964 }
951 }, 965 }, */
952 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat', columntype: 'dropdownlist', 966 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat', columntype: 'dropdownlist',
953 createeditor: function (row, column, editor) { 967 createeditor: function (row, column, editor) {
954 var srcUse = [ "Boil", "Dry Hop", "Mash", "First Wort", "Aroma" ]; 968 var srcUse = [ "Boil", "Dry Hop", "Mash", "First Wort", "Aroma" ];
955 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUse }); 969 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUse });
956 }, 970 },
998 ] 1012 ]
999 }); 1013 });
1000 $("#hopGrid").on('cellendedit', function (event) { 1014 $("#hopGrid").on('cellendedit', function (event) {
1001 var args = event.args; 1015 var args = event.args;
1002 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); 1016 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
1003 $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); 1017 if (args.datafield == 'grams') {
1018 $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, 'h_amount', parseFloat(args.value / 1000));
1019 } else {
1020 $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
1021 }
1004 // //$('#hopGrid').jqxGrid('sortby', 'f_amount', 'desc'); 1022 // //$('#hopGrid').jqxGrid('sortby', 'f_amount', 'desc');
1005 }); 1023 });
1006 }; 1024 };
1007 1025
1008 // Inline miscs editor 1026 // Inline miscs editor

mercurial