// ----------------------------------------------------------- // hdfDataGridLoad: // ---------------------------------------------------------- function hdfDataGridLoad(gridDomNodeID) { require(["dojo/ready", "dojo/data/ItemFileWriteStore", "dojox/grid/DataGrid", "dijit/registry", "dojo/dom"], function(ready, ItemFileWriteStore, DataGrid, registry, dom){ ready(function(){ if (registry.byId("hdmBannerDebug").checked) { console.log("hdfDataGridLoad hjsonGridData: ", hjsonGridData); } // Check if No Rows in a Subfile /* if (hjsonGridData.items.length == 0 && hjsonGridControl.env.cltype == "SUBFILE") { hdfDataGridNull(gridDomNodeID); return; } */ var dGridData = new ItemFileWriteStore({data: hjsonGridData}); var dataGrid = new DataGrid({ store: dGridData, structure: hjsonGridControl.structure, rowSelector: "10px", onRowContextMenu: function(evt) { hdfDataGridMenu(evt); dojo.stopEvent(evt)}, onHeaderCellClick: function(evt) { hdfDataGridHdrClick(evt); dojo.stopEvent(evt)}, jsId: "dataGridModel", //onStyleRow: function(inRow) { // hdfDataGridStyleRow(inRow)}, onApplyCellEdit: function(cellValue,rowNo,colName) { hdfDataGridEditGo(rowNo, colName, cellValue); }, autoWidth: false}, gridDomNodeID); dataGrid.startup(); if (registry.byId("hdmBannerDebug").checked) { //console.log("hdfDataGridLoad gliDataGrid: ", gliDataGrid); console.log("hdfDataGridLoad hjsonGridControl: ", hjsonGridControl); } }); }); return; } // ----------------------------------------------------------- // // ----------------------------------------------------------- function hdfDataGridMenu(evt) { globalRowIndex = evt.rowIndex; // Row Index if (!hjsonGridControl.contextmenu) { return; // No Context menu } console.log("hdfDataGridMenu evt.cellNode: ", evt.cellNode); require(["dojo/ready", "dijit/Menu", "dijit/MenuItem", "dijit/registry", "dojo/dom"], function(ready, Menu, MenuItem, registry, dom){ //var contextMenu; var contextMenu = new Menu({targetNodeIds: evt.cellNode}); var gridMenuStore = hjsonGridControl.contextmenu; if (registry.byId("hdmBannerDebug").checked) { console.log("hdfDataGridMenu sev: ", sev); console.log("hdfDataGridMenu gridMenuStore: ", gridMenuStore); } for (var i = 0; i < gridMenuStore.length; i++) { contextMenu.addChild(new MenuItem({ label: gridMenuStore[i].cap, iconClass: gridMenuStore[i].icon, onClick: function(evt) { if (registry.byId("hdmBannerDebug").checked) { console.log("hdfDataGridMenu evt onClick: ", evt); } var gridMenuStore = hjsonGridControl.contextmenu; for (var j = 0; j < gridMenuStore.length; j++) { if (gridMenuStore[j].cap == evt.target.innerHTML) { if (gridMenuStore[j].idx == "SQL") { hdfDataGridMenuSqlDrill(registry, gridMenuStore[j]); } else { hdfDataGridMenuGo(registry, gridMenuStore[j]); } return; } } } })); } contextMenu.startup(); dojo.connect(contextMenu, 'onClose', function() { contextMenu.uninitialize(); }); contextMenu._openMyself(evt); // spot of bother console.log("hdfDataGridMenu evt.cellNode: ", evt.cellNode); console.log("hdfDataGridMenu contextMenu: ", contextMenu); }); return; } // ----------------------------------------------------------- // hdfDataGridMenuGo: Select Menu Option from Context Menu // ----------------------------------------------------------- function hdfDataGridMenuGo(registry, gridMenuItem) { if (registry.byId("hdmBannerDebug").checked) { console.log("hdfDataGridMenuGo gridMenuItem: ", gridMenuItem); } var jsCaller = "hdfDataGridMenuGo"; var jsonObj = {}; switch (gridMenuItem.func) { case '*CUSTOM': jsonObj = hdfiServerSetJsonObj(jsCaller,"HWEBV2MD", "HWEBV2MD"); break; case 'iProgram': jsonObj = hdfiServerSetJsonObj(jsCaller,"ILEPGM" , "CE_Parms"); break; default: jsonObj = hdfiServerSetJsonObj(jsCaller,"HWEBNAEB1", "EB1_Parms"); } jsonObj.procparm = " "; jsonObj.gridenv = hjsonGridControl.env; if (hjsonGridControl.env.noofrows == 0 && hjsonGridControl.env.cltype == "SUBFILE") { jsonObj.gridenv.rowno = 0; } else { jsonObj.gridenv.rowno = globalRowIndex + 1; } jsonObj.gridmenu = gridMenuItem; globalgridMenuItem = gridMenuItem; var jsonUrl = hugmarSettings.host.pgmdir + "/hwebhtp120.pgm?json=" + hdfiServerSetJsonUrl(jsonObj); if (gridMenuItem.type == "maint") { hdjTabEdit(urlString); } else { hdfiServerGet(jsCaller, jsonUrl); } return; } // ----------------------------------------------------------- // // ----------------------------------------------------------- function hdfDataGridMenuRsp(response) { //console.log("hdfDataGridMenuRsp response: ", response); if (response.msgtype == "JSONGRID") { hugmarSettings.host.ifsctlpath = response.ifsctlpath; hugmarSettings.host.ifscolpath = response.ifscolpath; hugmarSettings.host.ifsgridpath = response.ifsgridpath; hugmarSettings.host.ifshdrpath = response.ifshdrpath; hdfTopCtl(); return; } // Needs further work rspText = response; var rspArray = rspText.split('~'); var elemCnt = rspArray.length / 2; var tempSev = null; var j = 0; var k = 1; for (var i=0; i" + "
" + "
" + "
" + "
" + "
" + ""; if (dijit.byId("hdmGridColHdrDialog")) { dijit.byId("hdmGridColHdrDialog").destroyRecursive(false); } var colHdrDialog = new dijit.Dialog({ title: "Set Filter: ", id: "hdmGridColHdrDialog", style: "width: 400px", content: colHdrContent}); colHdrDialog.show(); // Form Heading dojo.addClass("hdmGridColHdrHeading","gridHdrInfoHeading"); dojo.byId("hdmGridColHdrHeading").innerHTML = evt.target.textContent; hdfDataGridHdrButtons(); //console.log("hdfDataGridHdrClickRpg(2) hjsonCol.filt1: ", hjsonCol.filt1); if (typeof hjsonCol.filt1 === "undefined") {return}; //console.log("hdfDataGridHdrClickRpg(3) hjsonCol: ", hjsonCol); // Filter 1 (From) dojo.addClass("hdmGridColHdrFilt1Label","gridHdrInfoLabel"); dojo.byId("hdmGridColHdrFilt1Label").innerHTML = "Filter From"; if (dijit.byId("hdmGridColHdrFilt1")) { dijit.byId("hdmGridColHdrFilt1").destroyRecursive(false); } var hdwGridColHdrFilt1 = new dijit.form.TextBox({ value: hjsonCol.filt1, id: "hdmGridColHdrFilt1", style: "width:100px", onChange: function(evt) { hjsonCol.filt1 = hdwGridColHdrFilt1.get("value"); return; } }, "hdmGridColHdrFilt1"); // Filter 2 (To) dojo.addClass("hdmGridColHdrFilt2Label","gridHdrInfoLabel"); dojo.byId("hdmGridColHdrFilt2Label").innerHTML = "Filter To"; if (dijit.byId("hdmGridColHdrFilt2")) { dijit.byId("hdmGridColHdrFilt2").destroyRecursive(false); } var hdwGridColHdrFilt2 = new dijit.form.TextBox({ value: hjsonCol.filt2, id: "hdmGridColHdrFilt2", style: "width:100px", onChange: function(evt) { hjsonCol.filt2 = hdwGridColHdrFilt2.get("value"); return; } }, "hdmGridColHdrFilt2"); return; } // ----------------------------------------------------------- // hdfDataGridHdrClickStd: // ----------------------------------------------------------- function hdfDataGridHdrClickStd(evt, hjsonCol) { for (var i=0; i" + "
" + "
" + "
" + "
" + "
" + "
" + "
" + "
" + "
" + "
" + "
" + "
" + "
" + "
"; if (dijit.byId("hdmGridColHdrDialog")) { dijit.byId("hdmGridColHdrDialog").destroyRecursive(false); } var colHdrDialog = new dijit.Dialog({ title: "Column Attributes: ", id: "hdmGridColHdrDialog", style: "width: 400px", content: colHdrContent}); colHdrDialog.show(); // Form Heading dojo.addClass("hdmGridColHdrHeading","gridHdrInfoHeading"); dojo.byId("hdmGridColHdrHeading").innerHTML = evt.target.textContent; // Column Heading 1 dojo.addClass("hdmGridColHdrHdr1Label","gridHdrInfoLabel"); dojo.byId("hdmGridColHdrHdr1Label").innerHTML = "Column Headings"; if (dijit.byId("hdmGridColHdrHdr1")) { dijit.byId("hdmGridColHdrHdr1").destroyRecursive(false); } var hdwGridColHdrHdr1 = new dijit.form.TextBox({ value: hjsonCol.chd1, id: "hdmGridColHdrHdr1", style: "width:100px", onChange: function(evt) { hjsonCol.chd1 = hdwGridColHdrHdr1.get("value"); return; } }, "hdmGridColHdrHdr1"); // Column Heading 2 dojo.addClass("hdmGridColHdrHdr2Label","gridHdrInfoLabel"); dojo.byId("hdmGridColHdrHdr2Label").innerHTML = "- - - - - - - - "; if (dijit.byId("hdmGridColHdrHdr2")) { dijit.byId("hdmGridColHdrHdr2").destroyRecursive(false); } var hdwGridColHdrHdr2 = new dijit.form.TextBox({ value: hjsonCol.chd2, id: "hdmGridColHdrHdr2", style: "width:100px", onChange: function(evt) { hjsonCol.chd2 = hdwGridColHdrHdr2.get("value"); return; } }, "hdmGridColHdrHdr2"); // Column Heading 3 dojo.addClass("hdmGridColHdrHdr3Label","gridHdrInfoLabel"); dojo.byId("hdmGridColHdrHdr3Label").innerHTML = "- - - - - - - -"; if (dijit.byId("hdmGridColHdrHdr3")) { dijit.byId("hdmGridColHdrHdr3").destroyRecursive(false); } var hdwGridColHdrHdr3 = new dijit.form.TextBox({ value: hjsonCol.chd3, id: "hdmGridColHdrHdr3", style: "width:100px", onChange: function(evt) { hjsonCol.chd3 = hdwGridColHdrHdr3.get("value"); return; } }, "hdmGridColHdrHdr3"); hdfDataGridHdrButtons(); if (hjsonCol.fldtype == "A") {return}; // Character String if (hjsonCol.fldtype == "D") {return}; // Date if (hjsonCol.fldtype == "T") {return}; // Time if (hjsonCol.fldtype == "Z") {return}; // Time Stamp // Decimal Places dojo.addClass("hdmGridColHdrDecLabel","gridHdrInfoLabel"); dojo.byId("hdmGridColHdrDecLabel").innerHTML = "Decimal Places"; if (dijit.byId("hdmGridColHdrDec")) { dijit.byId("hdmGridColHdrDec").destroyRecursive(false); } var hdwGridColHdrDec = new dijit.form.NumberSpinner({ value: hjsonCol.dec, smallDelta: 1, constraints: { min: 0, max: 8, places: 0 }, id: "hdmGridColHdrDec", style: "width:100px", onChange: function(evt) { hjsonCol.dec = hdwGridColHdrDec.get("value"); return; } }, "hdmGridColHdrDec"); // Division Factor dojo.addClass("hdmGridColHdrDivLabel","gridHdrInfoLabel"); dojo.byId("hdmGridColHdrDivLabel").innerHTML = "Division Factor"; if (dijit.byId("hdmGridColHdrDiv")) { dijit.byId("hdmGridColHdrDiv").destroyRecursive(false); } var hdwGridColHdrDiv = new dijit.form.NumberSpinner({ value: hjsonCol.div, smallDelta: 1, constraints: { min: 0, max: 6, places: 0 }, id: "hdmGridColHdrDiv", style: "width:100px", onChange: function(evt) { hjsonCol.div = hdwGridColHdrDiv.get("value"); return; } }, "hdmGridColHdrDiv"); return; } // ----------------------------------------------------------- // // ----------------------------------------------------------- function hdfDataGridHdrButtons() { var hdrButton = dijit.byId("hdmGridColHdrBut0"); if (dijit.byId(hdrButton)) { hdrButton.destroyRecursive(true); } var hdrButton = dijit.byId("hdmGridColHdrBut1"); if (dijit.byId(hdrButton)) { hdrButton.destroyRecursive(true); } var parNode = dojo.byId("hdmGridColHdrButtons"); parNode.innerHTML = " "; //console.log("hdfDataGridHdrButtons parNode: ", parNode); // Confirm var butNode = document.createElement("span"); butNode.id = "hdmGridColHdrBut0"; parNode.appendChild(butNode); hdfDataGridHdrOneBut("hdmGridColHdrBut0", "Confirm", "gif38", "confirm", "Confirm Column Changes"); // Cancel var butNode = document.createElement("span"); butNode.id = "hdmGridColHdrBut1"; parNode.appendChild(butNode); hdfDataGridHdrOneBut("hdmGridColHdrBut1", "Cancel", "gif33", "cancel", "Cancel Column Changes"); return; } // ----------------------------------------------------------- // // ----------------------------------------------------------- function hdfDataGridHdrOneBut(domID, label, icon, action, title) { var hdrButton = dijit.byId(domID); if (dijit.byId(hdrButton)) { hdrButton.destroyRecursive(true); } var dom = dojo.byId(domID); var hdrButton = new dijit.form.Button({ label: label, iconClass: icon, jsId: action, onClick: function(evt) { var butNode = dijit.getEnclosingWidget(evt.target); //console.log("hdfDataGridHdrOneBut onClick butNode: ", butNode); hdfDataGridHdrConfirm(butNode.jsId); }, title: title}, dom); } // ----------------------------------------------------------- // // ----------------------------------------------------------- function hdfDataGridHdrConfirm(actionType) { if (actionType == "cancel") { if (dijit.byId("hdmGridColHdrDialog")) { dijit.byId("hdmGridColHdrDialog").destroyRecursive(false); } return; } var jsCaller = "hdfDataGridHdrConfirm"; var jsonObj = {}; switch (hjsonGridControl.env.cltype) { case 'RPGILE': jsonObj = hdfiServerSetJsonObj(jsCaller,"ILEPGM", "CE_Parms"); break; default: jsonObj = hdfiServerSetJsonObj(jsCaller,"HWEBV2BG5", "BG5_Parms"); } jsonObj.procparm = "colchange"; jsonObj.gridenv = hjsonGridControl.env; jsonObj.gridcol = hjsonCol; if (hdwBannerDebug.checked) { console.log("...DataGridHdrConfirm jsonObj: ", jsonObj); alert("...DataGridHdrConfirm Debug jsonObj: Check Console"); } var jsonUrl = hdfiServerSetJsonUrl(jsonObj); var stdUrl = hugmarSettings.host.pgmdir + "/hwebhtp120.pgm?json="; hdfiServerGet(jsCaller, stdUrl+jsonUrl); return; } // ----------------------------------------------------------- // // ----------------------------------------------------------- function hdfDataGridHdrConfirmRsp(response) { if (dijit.byId("hdmGridColHdrDialog")) { dijit.byId("hdmGridColHdrDialog").destroyRecursive(false); } if (hjsonGridControl.env.cltype == "RPGILE") { hdjAccMenuAppsGoRsp(response); // Refresh Grid } else { return; } } // ----------------------------------------------------------- // hdjViewLoadDnd: function to Load View Drag and Drop // ----------------------------------------------------------- function hdfDataGridEditGo(rowNo, colName, cellValue) { var jsCaller = "hdfDataGridEditGo"; var jsonObj = hdfiServerSetJsonObj(jsCaller,"ILEPGM","gridedit"); jsonObj.procparm = "gridedit"; jsonObj.gridenv = hjsonGridControl.env; jsonObj.gridenv.rowno = rowNo; jsonObj.gridenv.colname = colName; jsonObj.gridenv.cellvalue = cellValue; //console.log("hdfDataGridEditGo jsonObj: ", jsonObj); var jsonUrl = hdfiServerSetJsonUrl(jsonObj); var stdUrl = hugmarSettings.host.pgmdir + "/hwebhtp120.pgm?json="; hdfiServerGet(jsCaller, stdUrl+jsonUrl); return; }