Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
one script in beforeFactory need to be restricted for sorting the table columns
Maroju
<p>Hi,</p>
<p> </p>
<div> </div>
<div>I have a code in 'beforeFactory' to shuffle the table columns in the order which user gives as parameter, which should execute only when first time table is rendered. Next time i.e., while sorting this code execution need to be stopped. I tried by declaring one global boolean variable in initialize and making it true inside the column shuffling code. But it didnt worked. I guess after clicking sort, report is getting reloaded. Will anybody help me in restricting this code for sorting table.</div>
<div> </div>
<div>Thanks in advance.</div>
<div> </div>
<div>Maroju</div>
Find more posts tagged with
Comments
jfranken
<p>I'm not sure what the issue is, but here are a couple of suggestions:</p>
<p> </p>
<p>Make sure you are using setPersistentGlobalVariable and getPersistentGlobalVariable (include the "Persistent" part)</p>
<p>Also, sometimes checking boolean values can be trickier than it seems: </p>
<p> </p>
<p><a data-ipb='nomediaparse' href='
https://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/'>https://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/</a></p>
;
<p> </p>
<p>Regards,</p>
<p>Jeff</p>
Maroju
<p>Hi Jeff,</p>
<p> </p>
<p>Thanks for reply. I want to make one variable 'true' on click of sort on the report table column. How to capture the sort event on the report. I am not using group sorting. I am using the default sort provided by the birt.</p>
<p> </p>
<p>Regards,</p>
<p>Maroju</p>
Maroju
<p>Hi Jeff,</p>
<p> </p>
<p>Will you please help me in putting one string vale in application context scope and how to retrieve it in beforeFactory. I used persistence global variable but didn't worked.</p>
Maroju
<p>Hi Jeff,<br>
<br>
Please find mentioned url . Please explain me how i can do the "Setting application context objects from script is also possible". How is it possible. Can you please provide me script to do this.</p>
<p> </p>
<p>"<a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/38916-one-script-in-beforefactory-need-to-be-restricted-for-sorting-the-table-columns/#entry142427'>http://developer.actuate.com/community/forum/index.php?/topic/38916-one-script-in-beforefactory-need-to-be-restricted-for-sorting-the-table-columns/#entry142427"</a></p>
;
Maroju
<p><span style="color:rgb(90,90,90);font-family:'Source Sans Pro', sans-serif;">"Setting application context objects from script is also possible" is mentioned in the document but setting value to the AppContext was given in java. Can anyone please explain me how to set attribute to appContext from script.</span></p>
Clement Wong
<p>You want to perform a check before you run a report, but you don't know where to set a flag that would not be reset after a run?</p>
<p> </p>
<p>If you're using the BIRT Engine, then you can set session variables in your BIRT report design. For example, if you added this to your beforeFactory:</p>
<p> </p>
<p><span style="font-family:'courier new', courier, monospace;">reportContext.getHttpServletRequest().getSession().setAttribute("sorted", "true");</span></p>
<p> </p>
<p> </p>
<p>You can access this session variable in your JSPs, and from your report, you can retrieve the value:</p>
<p> </p>
<p><span style="font-family:'courier new', courier, monospace;">reportContext.getHttpServletRequest().getSession().getAttribute("sorted");</span></p>
Maroju
<p>Hi Clement,</p>
<p> </p>
<p> Thank you for the reply. </p>
<p> </p>
<div>1) Whatever you told is correct. But if i will be able to set "<span style="color:rgb(40,40,40);font-family:'courier new', courier, monospace;">reportContext.getHttpServletRequest().getSession().setAttribute("sorted", "true");"</span></div>
<div><span style="color:rgb(40,40,40);font-family:'courier new', courier, monospace;">on click of Sorting then only i will be able to achieve this. Please let me know the way to set this onClick of sorting. I didn't find any event such as onClick of sorting in designer. Is it possible through script anywhere? </span></div>
<div> </div>
<div>2) I need one more help. I have below code in beforeFactory</div>
<div> </div>
<div>var col = reportContext.getDesignHandle().getElementByID("1873");</div>
<div>col.setProperty("allowExport","true");</div>
<div> </div>
<div>id: 1873 represents column in a table. I would like to set property "allowExport = true" on column i.e., I would like to dynamically export the column through script. I wrote above script but it is giving error. Will you please help me in setting this property.</div>
Clement Wong
<p>1. You would have to provide more information. It is not clear how you design your report and in what context you have defined Sorting. Maybe you can provide a sample design?</p>
<p> </p>
<p>2. Report Items (such as Tables, Labels, Images, etc...) have the property <em>allowExport</em>. A column of a table does not.</p>
Maroju
<p>Hi Clement,<br>
<br>
Thank you for replying.<br>
<br>
I am attaching the sample report based on Classic Model database. In this report i have a report parameter in which user will give which table columns he want to see. So dynamically i need to show the user selected columns and some default columns. If i run the report first time all the columns i.e., user selected columns and default columns are coming properly. I have not written any sorting logic. I am using default sorting. But i wrote script in beforeFactory to shuffle the columns of the table and to show them on the screen. the code is as below<br>
<br>
if(tH!=null){<br>
<br>
for(i = 0; i < columns.length; i++){<br>
logToDebugWindow(columns.length);<br>
var r = columns.length - i - 1 ;<br>
var index = r;<br>
logToDebugWindow(columns[index]);<br>
var position = getColumnIndexFor(tH, columns[index]);<br>
var src = position + 1;<br>
var dest = index + 1;<br>
logToDebugWindow(src + " for " + columns[index] + " to position " + dest );<br>
//logToDebugWindow(tH.canShiftColumn(src, dest));<br>
if (tH.canShiftColumn(src, dest) == true) {<br>
tH.shiftColumn(src,dest);<br>
} <br>
}<br>
}<br>
<br>
If i click sort, first column is getting replaced with the first column of the table. Default columns to show on the screen in the attached sample report are CUSTOMERNAME,CONTACTLASTNAME and CONTACTFIRSTNAME. For example if i give two column names in the report parameter as CITY and STATE, and if i run the report resulted report table is coming with "CUSTOMERNAME,CONTACTLASTNAME ,CONTACTFIRSTNAME,CITY and STATE ". After this, if i click sorting on any of the columns then the first column i.e., CUSTOMERNAME is getting replaced with CUSTOMERNUMBER which is the first column of the default table in the report. When i am continuously sorting, CUSTOMERNUMBER column is getting shifted one place forward and after two times or three times i am unable to sort. <br>
<br>
This is all happening because of the above mentioned shuffling code. I need this shuffling logic to be executed when first time report loads. I want to restrict execution of this logic when sorting is clicked. Please help me to achieve this.</p>
Maroju
<p>Hi Clement,</p>
<p> </p>
<p> Thank you and sorry for the trouble. The issue is with "<span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">var dest = index + 1;</span>" this part of the above code. If i give simply index without increment, column shifting has stopped. But one issue is i am unable to see sorting symbols i.e., up arrow key or down arrow key after sorting two or three times. Will you please check the rpt attached in the previous comment and let me know. </p>
<p> </p>
<p>Thanks in advance.</p>
Clement Wong
<p>I was able to replicate your issue after updating the line "var dest = index + 1;" to "var dest = index;" I'm not sure why the icons disappear from the top of the column. The right click menu option for IV options still work (Header, Group, Column, Aggregation, Filter, Sort, Alignment, Format, Export Content). You should log a Support ticket to see if they can provide further assistance.</p>
<p> </p>
<p><span style="color:#008000;"><strong>TIP </strong> </span>Since you are using commercial BIRT, instead of outputting debug statements to a new window, you can use the following code snippet that outputs directly out to Eclipse's Error Log in the lower right pane. Only 1 line of code for setup and you won't get multiple windows.</p>
<pre class="_prettyXprint">
logger = java.util.logging.Logger.getLogger("birt.report.logger");
logger.warning ("Your message here.");</pre>
Maroju
<p>Hi Clement,</p>
<p> </p>
<p> Thanks for the reply. I will log the Support ticket for icon invisible issue and also thanks for the code for error logging.</p>