Hopefully this is simple but I can't seem to figure it out.
I made an action button in the freeform edit region of the search part of my grid.
In defining that button I picked the "open a report" helper function and filled in my information.
I wanted it to prompt for beginning and ending dates so I converted that action to text mode and added the relevant code.
I then wanted a custom button in the report window that allows the user to export the report to excel instead of printing it so I made another button with the export to excel action, converted it to text mode and took that code and put it in my report button.
It works perfect the first time my button is clicked. On subsequent clicks; however, the report works fine but the export to excel function seems to cache the dates that were used the first time. Refreshing the browser or closing the tabbed ui tab that the button is in clears this cache and allows it to work properly.
Is there a way to make it clear the variables out and figure them each time the button is clicked?
The conglomerated code looks like this:
Here's a screen shot for clarification of what I'm working on.
exportreport.png
I made an action button in the freeform edit region of the search part of my grid.
In defining that button I picked the "open a report" helper function and filled in my information.
I wanted it to prompt for beginning and ending dates so I converted that action to text mode and added the relevant code.
I then wanted a custom button in the report window that allows the user to export the report to excel instead of printing it so I made another button with the export to excel action, converted it to text mode and took that code and put it in my report button.
It works perfect the first time my button is clicked. On subsequent clicks; however, the report works fine but the export to excel function seems to cache the dates that were used the first time. Refreshing the browser or closing the tabbed ui tab that the button is in clears this cache and allows it to work properly.
Is there a way to make it clear the variables out and figure them each time the button is clicked?
The conglomerated code looks like this:
Code:
window['{grid.componentName}_G_ACTIONBUTTON_PCREPORT_1'] = function(objEle) { var rowNum = {grid.object}._selectedRow; var rowId = $u.s.tran(rowNum,'-','_'); var date1 = '' var date2 = '' var datestring = prompt('Please enter the dates between which you would like to run this report. Separate the dates with two dots like the default example below:','01/01/2012..01/01/2013'); if(datestring!=null) { date1 = datestring.split('..').shift(); date2 = datestring.split('..').pop(); } window['{Grid.ComponentName}_ACTIONBUTTON_PCREPORT_1'] = {Grid.object}.getWindow('WINDOW_a05501da_c7da_40c8_b3e1_8137f37fb33c' ); if(!window['{Grid.ComponentName}_ACTIONBUTTON_PCREPORT_1']) { window['{Grid.ComponentName}_ACTIONBUTTON_PCREPORT_1'] = {grid.object}.createWindow('WINDOW_a05501da_c7da_40c8_b3e1_8137f37fb33c','modal-url-resizable',{ height: '5in', width: '8in', title: { html: 'Window', location: 'top', show: true }, disableMove: false, theme: '{grid.style}', body: { content: { type: 'url', url: '__workingMessage.a5w' } }, onHide: function() { $(this.getWindowId('body')).src = '__workingMessage.a5w';}, buttons: { items: [ { html: 'Export To Excel', name: 'Export To Excel', action: function() { var placeHolderValues = ''; var arguments = 'Date1|Time|'+date1+'||Date2|Time|'+date2+''; //alert(date1 +' '+date2); var callbackData = '_csfilename=%3cDefault%3e&_exportDataType=Excel%2dXLSX&_recordSelection=Records%20in%20current%20query&_exportSource=4&_maxRecords=10000&_exportHiddenFields=Y&_useColHeadings=Y&_zip=N&_customType=SQL&_connectionstring=%3a%3aName%3a%3aAutocrib&_sqlselect=SELECT%20a%2eitem%2c%20b%2edescription1%2c%20a%2eprices%2c%20a%2ehighprice%2c%20a%2elowprice%2c%20a%2edifference%2c%20a%2epercentdiff%20FROM%28SELECT%20item%2c%20COUNT%28DISTINCT%20unitprice%29%20prices%2c%20MAX%28unitprice%29%20AS%20highprice%2c%20MIN%28unitprice%29%20AS%20lowprice%2c%20MAX%28unitprice%29%2dMIN%28unitprice%29AS%20difference%2c%20100%2d%28MIN%28unitprice%29%2fMAX%28unitprice%29%2a100%29%20AS%20Percentdiff%20FROM%20MyTran%20WHERE%20type%20IN%20%28%27PO%27%2c%27PE%27%2c%27P%27%29%20AND%20mydate%20BETWEEN%20%3aDate1%20AND%20%3aDate2%20GROUP%20BY%20item%20HAVING%20COUNT%28DISTINCT%20unitprice%29%20%3e%201%29%20AS%20A%20LEFT%20JOIN%20item%20AS%20B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ON%20a%2eitem%3db%2ecode'; callbackData = callbackData + '&_placeholderValues='+placeHolderValues + '&_arguments='+arguments; {grid.Object}.ajaxCallback('G',rowNum,'__a5systemfileExport','',callbackData);}, disabled: false, show: true }, { html: 'Close', name: 'Close', action: 'Close', disabled: false, show: true } ], style: '' } } ); }; var ro = new Object(); ro.hostComponentType = 'Grid'; ro.reportName = '[email protected]'; ro.reportNameShort = 'ACPriceChange'; ro.reportType = 'Report'; ro.reportIFrame = window['{Grid.ComponentName}_ACTIONBUTTON_PCREPORT_1'].getWindowId('body');; ro.gridId = '{grid.componentName}'; ro.download = 'N'; ro.xbasicFunction = ''; ro.clientSideFilename = ''; ro.reportMessagesDivId = ''; ro.filter = ''; ro.order = ''; ro.sqlFilter = ''; ro.sqlOrder = ''; ro.arguments = 'Date1|Time|'+date1+'||Date2|Time|'+date2+''; ro.workingMessage = '<img src="CSS/A5System/images/wait.gif" />Working...'; ro.pdfoptions = ''; ro.displayMode = ''; ro.saveAs = 'pdf'; ro.pdfOpenParameters = '' ; ro._gridCurrentFilter = {grid.object}._gridFilter; ro._gridCurrentOrder = {grid.object}._gridOrder; ro._gridCurrentArguments = {grid.object}._gridArguments; ro._gridCurrentDBType = {grid.object}._gridDBType; ro.afterExecuteJavascript = ''; if(A5.__dtfmt) ro.__dtfmt = A5.__dtfmt; ro.htmlReporting = false; if({grid.object}._embeddedMode) { var callWorkingPreview = true; if( typeof ro.htmlReporting == 'object' ) { if( ro.htmlReporting.initialView == "HTML" ) { callWorkingPreview = false; } } if( callWorkingPreview ) { ro.windowType = 'Modal'; reportPreviewFromWorkingPreview(ro); return false; } } A5.component.runReport(ro); window['{Grid.ComponentName}_ACTIONBUTTON_PCREPORT_1'].show(); }
exportreport.png
Comment