does anyone know how to set the height of the detail section in my report programatically (e.g. in detail_format or after/before_print methods)?
Setting the (float) height in detail_format for each datasource row has no effect.
Do I have to set the "Can Grow" / "Can Shrink" properties to FALSE?
Thanks in advance,
Walter
I would suggest keeping the CanGrow and CanShrink properties as it is (default). The detail section grow as each row renders. You can manually set the height of the detail section like this:
private void detail_Format(object sender, EventArgs e)
{
this.detail.Height = 7f;
}
However without any details about your requirements, I am unable to offer any other suggestions.
Related
Some lists and tables gray out their selection when they lose keyboard focus.
In the presence of multiple lists/tables, this helps communicate to the user which selection is active.
Is there an easy way to do this with NatTable?
The best I've come up with so far is to flip between different attributes for DisplayMode.SELECT as focus comes and goes -- but I'm not sure I can do that after NatTable.configure() has been called.
Yes you can change configuration attributes dynamically after NatTable#configure() has been called. That is a common approach for dynamic changes. Another approach would be to configure a selection style for a special label and apply that label only in case the table is active. This approach can be seen in this example.
https://github.com/eclipse/nebula.widgets.nattable/blob/master/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_500_Layers/_505_Selection/_5054_SelectionProviderExample.java
I have this working, after #DirkFauth's answer. This answer includes some specifics.
After the table has been configured with NatTable.configure(), you can modify the configuration not with NatTable.addConfiguration(IConfiguration), but instead by calling IConfiguration.configureRegistry(IConfigRegistry). For example:
myConfiguration.configureRegistry( myTable.getConfigRegistry() )
Within that implementation of configureRegistry(), you can set the style for selected and anchor cells:
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE,
selectedStyle, DisplayMode.SELECT, GridRegion.BODY);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE,
anchorStyle, DisplayMode.SELECT,
SelectionStyleLabels.SELECTION_ANCHOR_STYLE);
When the table is inactive, selectedStyle and anchorStyle can be modified clones of their usual setting. For example:
private static Color myInactiveColor = ...;
public static Style makeInactiveBodyCellStyleFrom(#Nonnull Style style) {
Style rv = style.clone();
rv.setAttributeValue( CellStyleAttributes.BACKGROUND_COLOR,
myInactiveColor );
return rv;
}
Similar work can be done for the styles of selected row and column headers.
I am using crystal report for printing details. I have two issues while printing.
Set height/width dynamically for section details
I want to change the height and width for the section dynamically through code. This height and width will come from user settings so I need those to be dynamic. When I checked, there is a option to set the section height programmatically but its not working. I am using the below code to set the section height
ReportDocument rd = new ReportDocument();
Section section = rd.ReportDefinition.Sections["Section3"];
section.Height = 1;
When I use this code, it gives me error "System.Runtime.InteropServices.COMException: The section height is not valid."
I also want to set "Gap Between Details" dynamically. Is it possible?
Set page content height dynamically
I want to set the page content height dynamically. We can set the page height and width from Design -> Page setup -> Page options -> Set Horizontal and Vertical values.
What is happening in my case is, I am using crystal report tp print barcodes. When the page height is big, it prints empty barcodes which I dont want. I want to set the page content height based on the number of barcodes I am going to print. How can I do this?
Can anybody help me solve these two issues?
I was finding how to resolve this question. For me, this works:
ReportDocument rd = new ReportDocument();
rd.ReportDefinition.Sections["Section5"].Height = 1000;
Try this, ok?
I added a formula field called AutoHeight and a parameter field called Height then I put this code inside the formula:
Local StringVar height = "";
Local NumberVar i;
For i:=1 to {?#Margin} do (
height := height + Chr(10)+Chr(13)
);
height
The final step is to place my AutoHeight formula in the section I want to control with the property Can grow checked
I use iReport and I try to fix a detail band's height independently of its content. My problem is that if one of my text fields has more than one line, the band "grows" and because of this I get a second page.
So is there any possibility to hard fix the height of a detail band?
Try setting the stretch type for the text field to "No Stretch" and the split type (see the properties menu) for the detail band to "Prevent".
Since we could not find any direct options, We are doing this in an indirect method, having PLSQL Procedure for data fetching, different sub-datasets are used for filling fixed height detail areas, so each fixed datasets are filled with max.rows which it can accomodate (within sub procedures). Hope it helps someone.
I've read there's no way to handle mixed orientations natively using iReport, however reading the documentation I wonder if by using JRDefaultScriptlet's beforePageInit() it could be accomplished somehow. In my case there's a portrait front page, as many landscape pages as there's data to populate them, and a last frontal page.
On the other hand does anybody know:
If this is a feature to be supported in the near futureIf there's an alternative that does as requested and generates a jasper-compliant xml file
Thanks in advance.
So I decided to play around with iReport and see what options there where for this. Turns out it is sort of possible to pull off, with some effort and imagination. This is assuming your first page is in the Title Section, and your Last Page is in the summary section.
Create your report in landscape mode.
Under Report Properties in iReport set Title on New Page and Summary on New Page to true.
Assuming you are using a standard 8.5" X 11" Letter sized page with all the margins set to 20, set the height of the Title and Summary sections to 572.
Add your static text fields into the appropriate section.
Now for each static text field you need to set the Rotate property to Left (well it could actually be Right, the point is they all need to be the same.
Of course add the all the other fields you want into the appropriate bands for page header, data, etc.
Export your report.
Note: if you have any images that need to go into the Title or Summary Section your will need to rotate them appropriately outside of iReport and save it. Then set the rotated image as the image in the report. Unfortunately the image tag does not seem to have a rotate property, as that would make life to easy.
Also if you do not set the properties listed in step 2 you will not be able to set the height of the Title and Summary bands to the appropriate width. If you are using a different size paper and/or
margins the easy way to figure out the max size (which is what you will need) is to set the height of the band to a very large number. It will then popup and tell you it is to large, and what the max size actually is.
There is no support to mixed landscape and portrait subreport, in the future they will add an object call JasperBook or something like that where you can add different subreports of different orientations without problems, but for the moment you have simulate that by doing different reports and join them just before showing them.
I.E.
//Create the reports separately
InputStream report1 = (InputStream) getClass().getResourceAsStream("/com/app/jasper/reportPortrait.jasper");
InputStream report2 = (InputStream) getClass().getResourceAsStream("/com/app/jasper/reportLandscape.jasper");
InputStream report3 = (InputStream) getClass().getResourceAsStream("/com/app/jasper/reportPortrait.jasper");
JasperPrint jasperPrint = JasperFillManager.fillReport(report, map, conn);
JasperPrint jasperPrint2 = JasperFillManager.fillReport(report2, map, conn);
JasperPrint jasperPrint3 = JasperFillManager.fillReport(report3, map, conn);
JRPdfExporter exp = new JRPdfExporter();
//Add the JasperPrint objects to an ArrayList
List list = new ArrayList();
list.add(jasperPrint);
list.add( jasperPrint2 );
list.add(jasperPrint3);
//And say to the exporter to join the list of reports.
exp.setParameter(JRPdfExporterParameter.JASPER_PRINT_LIST, list);
exp.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream());
exp.exportReport();
I'm doing that in my reports and it works. Good luck!
I am using MasterDetailsBlock on my FormPage. I would like to adjust the screen width for the master and details part of the form. I had been searching around and haven't found a way to do it. The documentation seems to suggest it is doable through the SashForm, but I do not see how.
It will be great if I can use percentage ratio, like the FormAttachment style, but if that is not possible..I'm ok to fix the master and details to specific pixel also.
Just use SashForm.setWeights(int[]) to modify the weights of the master and the detail in the MasterDetailsBlock.
The weights describe the size ratio of the SashForm's parts. {1, 2} for examble would make the detail twice as wide as the master.
In your MasterDetailBlock class, override the registerPage() method, set your all detail pages, then call sashform.setweights(int [])
Example:
protected void registerPages(DetailsPart part) {
part.registerPage(MemoryBudgetImpl.class, new MemoryBudgetDetailPage());
sashForm.setWeights(new int[]{1,3});
}