Jump to content
We've recently updated our Privacy Statement, available here ×

Trick: Re-Order Detail Bands


jpauze

Recommended Posts

If there is another way to do this, someone please speak up because I haven't found it and hopefuly they will add a design mode way of doing this.

Scenario: 

You are in the middle of creating a report and you have a number of detail bands, now you need to add a new one, when you add a detail band it is automatically placed as the last detail band, ok great, but I need it to be the first, or second, or wherever and yet there is no move detail band function in the U/I.  

Solution:

May sound simple but it works,  switch to XML view and move the detail band where you want it.  In the example below I want to move the empty 2nd band to be the 1st band.

Before...

<detail>
     <band height="22">
          <textField>
          <reportElement mode="Transparent" x="0" y="2" width="373" height="20"/>
          <textElement>
          <font size="11" isBold="true"/>
          </textElement>
          <textFieldExpression class="java.lang.String"><![CDATA["Text Field 2"]]></textFieldExpression>
          </textField>
     </band>
     <band height="22"/>
</detail>

After...

<detail>
     <band height="22"/>
     <band height="22">
           <textField>
           <reportElement mode="Transparent" x="0" y="2" width="373" height="20"/>
           <textElement>
           <font size="11" isBold="true"/>
           </textElement>
           <textFieldExpression class="java.lang.String"><![CDATA["Text Field 2"]]></textFieldExpression>
           </textField>
      </band>
</detail>

Caution, be extremely careful modifying XML structure, if you mess it up your report will be corrupted and will not open in design mode.

Link to comment
Share on other sites

  • 3 weeks later...
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I think your way is the best generic solution for this.  I just ran into this yesterday, but I was lucky:  my Detail band consisted only of a Frame element, which in turn contained all my fields (I mainly do this so the Frame can be the element that contains conditional formatting for a green bar effect), so I was able to create a Detail2 record, copy my frame from Detail to Detail2, verify all looks good, then delete the frame from Detail band.

Oh, and my Detail and Detail2 band had mutually exclusive Print when conditions, so the order didn't really matter, but I guess I'm anal, and I really wanted the new version I was inserting to appear above the version I already had when I looked at the design view, just because of the nature of the data in each of the two versions of the detail.

Carl

Link to comment
Share on other sites

had some that didn't depend on order but wanted then in a specific order in the designer, also had some that required a specific order and at first i would add new band to the bottom then move all elements down one band and reset the print expressions to free up the band i wanted to add on.  Total pain, the adjust through XML certainly makes life easier.  

At some point I will create a feature request to have an insert detail band from the designer.

 

 

Link to comment
Share on other sites

Yes, after seeing that the order of the bands are only defined by the order in which they appear in the jrxml, I'm a little surprised you can't just drag an existing Detail into a different order in the Report Inspector tree (and of course, have the "Detail x" renumber appropriately...this number x looks like it only appears in the tree as a temporary display ordinal, not in the jrxml itself).  I'd be fine with it always creating a new detail band at the end, as long as I could drag it to the location I really want it in either immediately after or any time down the road.  The drag option would solve problems of redesign that an insert-to-specific-location alone doesn't solve.  And the drag-to-reorder paradigm is already used elsewhere in that tree (I sometimes reorder elements within a band to more logically match their left-to-right position order on the display), so it would be very intuitive.

Carl

Link to comment
Share on other sites

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...