jbenway Posted September 10, 2014 Share Posted September 10, 2014 I need to display data that is coming in from one field in two different text fields, depending on an attribute of that data. The result should be two columns, similar to what you would get in a table.My data comes in XML formatted like this:<color> blue <type>dark</type></color><color>red<type>light</type></color><color> green <type>dark</type></color><color>yellow<type>light</type></color>What I want the output to be is:DarkLightblueredgreenyellowI put these onto my report with two textfields and a print when expression. Each field displays "color" but the one on the left displays when type=dark, and the one on the right prints when type=lightUnfortunately, this results in a output like this:DarkLightblue redgreen yellowIs there another way I can do this that will let me sort my two types of data from a single field into two table-like columns? Link to comment Share on other sites More sharing options...
AnnMary.Thomas Posted September 12, 2014 Share Posted September 12, 2014 For each text field set Remove Line when Blank to true. And also set each text field Position Type to Float. Link to comment Share on other sites More sharing options...
jbenway Posted September 12, 2014 Author Share Posted September 12, 2014 Thank you so much for the response! Unfortunately, making these changes doesn't seem to help. I think it might be because the, as the hover text for remove line when blank says, it collapses the band if the element is not printing AND no other element is occupying the same horizontal space. I'm guessing that "green" in my example above is not moving up next to "red" because red is occupying horizontal space. As an experiment, I tried lining my two fields up vertically: $F{color} $F{color} and in this case the setting you recommend does close up those blank lines. However, I need the two fields to be alongside each other. Link to comment Share on other sites More sharing options...
Solution AnnMary.Thomas Posted September 15, 2014 Solution Share Posted September 15, 2014 Another way od doing this would be to use the List Component.Drag 2 list components, one for Dark and seconf for Light. Set the datasources of these two lists to ur XML.Set the Print order property of the Lists to be VerticalPlace the Lists Sided by Side Add one text field to each List. Set the first text field PrintWhen expression to type =Dark and the second one PrintWhen expressin to type =Light.This should solve your problem. Hope tis helps Link to comment Share on other sites More sharing options...
jbenway Posted September 16, 2014 Author Share Posted September 16, 2014 Thank you! This worked, with a fair amount of tweaking. I really appreciate it. The keys were a) to start with this tutorial on lists, which are more complex that other stuff I've done so far: http://community.jaspersoft.com/wiki/lists-jaspersoft-studio Also, I had a lot of trouble mapping the "type" field properly for use with a PrintWhen expression. What I ended up doing instead was to create two separate fields in the dataset that I created (based on the tutorial), one for ColorDark and the other for ColorLight. To define ColorDark in the dataset, I used color[../type=dark] Then I created two separate lists as you suggested, each with a textfield mapped to their own field, and set it to Blank when Null and Remove Line When Blank Link to comment Share on other sites More sharing options...
AnnMary.Thomas Posted September 17, 2014 Share Posted September 17, 2014 If my answer has helped you please check this as answered :) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now