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)
Hiding rows based on dynamic text column output.
miwalker
I have a table in my report with a dynamic text column that's populated based on values from other columns. Here's an example of what the dynamic text would look like with the Sample DB:<br />
<br />
if ((row["CITY"] == "Singapore") && (row["CUSTOMERNUMBER"] > 100)) {<br />
devPriority = "1";<br />
}<br />
else if (row["CUSTOMERNAME"] == "Muscle Machine Inc") {<br />
devPriority = "2";<br />
}<br />
else if (row["STATE"] =="CA") {<br />
devPriority = "3";<br />
}<br />
else {<br />
devPriority = "4";<br />
}<br />
<br />
I'd like to be able to filter out all rows that have "4" for this column. I assume I can't use the Filter option as the column doesn't appear in the list. I then tried Visibility at the Row level and specified <br />
<br />
<strong class='bbc'>devPriority == "4";</strong><br />
<br />
It hid all the "4"s except for the first one. I'm assuming this is because it evaluates the Visibility expression before the Dynamic Text expression. I tested this by changing the variable declaration in the onPrepare script for the Dynamic Text column from <strong class='bbc'>devPriority = "";</strong> to <strong class='bbc'>devPriority = "4";</strong> It then hid the first "4" as well.<br />
<br />
Is there anyway to filter or hide values from a dynamic text column? I have to use a dynamic text field because the data in the columns are from multiple datasets. <br />
<br />
Thanks,
Find more posts tagged with
Comments
mwilliams
Hi miwalker,
You could possibly use a hidden table set up the same that you use to determine whether a row in the next table is hidden.
I would think you would be able to use the first table as your dataSet for you second table, so you don't have to access your database twice.
miwalker
Michael,<br />
<br />
I still seem to have the same problem with the dynamic text field. When I hide the table and create a 2nd table with the 1st table as the dataSet it doesn't list the dynamic text field in the data binding.<br />
<br />
Using the example from my previous topic that you helped me on...I tried putting the dynamic text value in the array using a variable like below:<br />
<strong class='bbc'><br />
if ((row["CITY"] == "Singapore") && (row["CUSTOMERNUMBER"] > 100)) {<br />
devPriority = "1";<br />
}<br />
else if (row["CUSTOMERNAME"] == "Muscle Machine Inc") {<br />
devPriority = "2";<br />
}<br />
else if (row["STATE"] =="CA") {<br />
devPriority = "3";<br />
}<br />
else {<br />
devPriority = "4";<br />
}<br />
</strong><br />
<br />
My row level OnCreate script for the array looks like this:<br />
<strong class='bbc'> <br />
myArray[i*1] = devPriority;<br />
myArray[i+1] = row["CUSTOMERNAME"];<br />
myArray[i+2] = row["CUSTOMERNUMBER"];<br />
myArray[i+3] = row["CITY"];<br />
myArray[i+4] = row["STATE"];<br />
i=i+5;<br />
</strong><br />
<br />
I then try to redisplay the array in a scripted dataset thinking I could sort and filter there. However the timing is off with the variable as it's evaluating devPriority before the row is fetched. So the first row redisplayed is blank for devPriority and the 2nd row matches the first row of data.<br />
<br />
I tried moving the array to different scripts (i.e onRender, table level) but it still seems to evaluate the variable before row retrieval.<br />
<br />
Do you know if this is possible to do? I would think that if I can get the variable to be populated after the row is retrieved and link my 2nd table to the scripted dataset I could solve both my sorting and filtering issues.<br />
<br />
Thanks.
mwilliams
miwalker,
The way I did it in this report seems to work. For some reason, when I sort the second table by the new binding, the value doesn't show up, but by adding the dynamic text to the second table as well, I was able to see that the sorting works correctly. Let me know if this works or if you have questions/issues.
miwalker
Michael,
I can't open the report. I'm on version 2.3.2. The message says the report is from 3.2.20.
I tried adding the dynamic text to the 2nd table but I still couldn't sort. I'm curious how you did it.
mwilliams
I just realized you wanted hiding and I did sorting anyways, so I'll see if this approach works for hiding as well. I'll post the example if I get it working in 2.3.2.
mwilliams
miwalker,
Here is the example of hiding rows based on a dynamic text box. The first table is hidden. Inside the dynamic text box, the current row value is added to an array. In the second table, the array is called back in the data element, creating a binding that you can work with in the table. This allows you to hide the "4" rows. Hopefully this works for you. Let me know.
miwalker
Thanks Michael.<br />
<br />
I added the code to my report and it looks like it's working. I appreciate your help.<br />
<br />
Regarding my other issue...sorting the column.<br />
<br />
If I placed the rows from the 2nd table (hidekey, customername, customer number, city, state) in another array, sort, then redisplay in a 3rd table, this should sort the Priority 1, 2, and 3 in correct order right? Do you think this would work for sorting?<br />
<br />
I tried using the table sort on the 2nd table and choosing hidekey but it made the whole column disappear. Sorting on sOrder
sorts that column but not the whole table.
mwilliams
Try naming the second table and using it as a source for your third table. When I tried to sort the new binding in the second table before, it made the column value disappear as well. I haven't tried to do this yet, so I'm not sure if it'll work as expected or not. Let me know.
miwalker
Michael,
Using the 2nd table as the source for the 3rd didn't work for me. By doing that it wouldn't allow me to select the Sort column on the 3rd table. I'm guessing because it wants you to sort on the 2nd table.
What did work was going back to the scripted dataset option. I placed the rows from the 2nd table in an array and passed it to the scripted dataset. I then used this scripted dataset as the source for the 3rd table, hid any rows that contained "4" in the hideKey column and then sorted on the hideKey column. This sorted the column and kept the values in the other columns correct. I wish I had looked at the built-in Sort first as I was trying to do it through the Array sort function before finally looking at the built-in Sort.
I think the key to this solution was you making the hideKey column a data element, which allowed the Sort.