Udostępnij za pośrednictwem


Runtime modification of Auto Design report sections

When you use Auto Design sections in your reports you don’t have to worry a lot about the design of the report. Everything will print just nicely.

But Auto Design is problematic to work with if you want to runtime change one of the reports controls in the section. It could be that you for some reason want to hide a field in certain circumstances. You can’t really do that from the code because the report controls of an Auto Design section can’t be referenced from the code - they only exist as meta data.

When report starts to run, the meta data from the Auto Design is however converted into real report section objects. I.e. it creates a Generated Design behind the scenes. The trick in this case is to get hold of the section objects from the Generated Design.

Here is an example made in 3.0 with the report CustPhoneList. In the example I have set a frame around each field and made the text in each field in italics.

And here’s the code overriding send on the report to do it:

 
public boolean send(Common _cursor, int _level=1, boolean _triggerOffBody=TRUE, boolean _newPageBeforeBody=FALSE) 
{ 
    boolean ret; 
    ReportSection reportSection; 
    ReportStringControl reportControl; 
    Counter controlCount; 
    ; 
    reportSection = element.design().sectionName('CustTable_1'); 
    for (controlCount = 1; controlCount <= reportSection.controlCount(); controlCount++) 
    { 
        if (reportSection.controlNo(controlCount).controlType() == ReportFieldType::String) 
        { 
            reportControl = reportSection.controlNo(controlCount); 
            reportControl.lineAbove(LineType::Solid); 
            reportControl.lineBelow(LineType::Solid); 
            reportControl.lineLeft(LineType::Solid); 
            reportControl.lineRight(LineType::Solid); 
            reportControl.italic(true); 
        } 
    }     ret = super(_cursor, _level, _triggerOffBody, _newPageBeforeBody); 
    return ret; 
} 

The send method may not be the best place to put this code, but until now that’s the only place I have been able to make it work…

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at https://www.microsoft.com/info/cpyright.htm

Comments