Dynamic Column width in BI Publisher

Dynamic Column width in BI Publisher

This has been a complex task to assign width of column dynamically in BI Publisher. This means number of columns is not fixed and they will come dynamically from XML and we want width of the columns to be distributed equally or in some ratio. Combined width of all columns assigned dynamically will be taken up from the width that we assign to that particular column. If there is only single column coming from XML then it will take up all width. If there are multiple columns then the width will be equally distributed or we can define in which ratio it should be distributed.

How it is done ?

Here is an example of how it can be done in BI Publisher.

1. Load Below XML:


< ?xml version="1.0" encoding="utf-8"?>
< TestScoreTable>
< LIST_COLUMNS>
< LIST_COLUMN>
< LIST_COLUMN_HEADING>Current Terms< /LIST_COLUMN_HEADING>
< /LIST_COLUMN>
< LIST_COLUMN>
< LIST_COLUMN_HEADING>2 - 30 Days< /LIST_COLUMN_HEADING>
< /LIST_COLUMN>
< LIST_COLUMN>
< LIST_COLUMN_HEADING>31 - 60 Days< /LIST_COLUMN_HEADING>
< /LIST_COLUMN>
< LIST_COLUMN>
< LIST_COLUMN_HEADING>61 - 90 Days< /LIST_COLUMN_HEADING>
< /LIST_COLUMN>
< LIST_COLUMN>
< LIST_COLUMN_HEADING>91 - Plus Days< /LIST_COLUMN_HEADING>
< /LIST_COLUMN>
< /LIST_COLUMNS>
< TestScores>
< TestCategory>Mathematics< /TestCategory>
< TestScore width ="15">
< TestScoreRange>0-20< /TestScoreRange>
< NumofStudents>30< /NumofStudents>
< /TestScore>
< TestScore width ="10">
< TestScoreRange>21-40< /TestScoreRange>
< NumofStudents>45< /NumofStudents>
< /TestScore>
< TestScore width ="15">
< TestScoreRange>41-60< /TestScoreRange>
< NumofStudents>50< /NumofStudents>
< /TestScore>
< TestScore width ="10">
< TestScoreRange>61-80< /TestScoreRange>
< NumofStudents>102< /NumofStudents>
< /TestScore>
< TestScore width ="15">
< TestScoreRange>81-100< /TestScoreRange>
< NumofStudents>22< /NumofStudents>
< /TestScore>
< /TestScores>
< /TestScoreTable>

2. create below template in BIP.

template in BIP

3. Modify code in template according to below table as shown in image below:

    Text To Display        Code    
  Group:TestScore    < ?for-each:TestScores?>  
  < ?TestCategory?>    < ?TestCategory?>  
  Column Header and Splitting    < ?split-column-header:TestScore?>< ?split-column-width:@width?>< ?TestScoreRange?>  
  Content and Splitting    < ?split-column-data:TestScore?> < ?NumofStudents?>  
  End:TestScore    < ?end for-each?>  


BI Publisher

4. Hit Pdf under BI Publisher and your pdf will be like shown below:


BI Publisher
Here you can see that we have defined width of each column in XML like .
If we remove one or two columns and see output then we will see that width of these columns has been distributed in others.

BI Publisher

0 comments:

Post a Comment