Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Change column order with a parameter
julienemixis
<p>Hello everybody,</p>
<p> </p>
<p>I would like to change dynamically columns order in my birt report with a parameter.</p>
<p>For example, i will receive a parameter with : "vehicle, reference, platenumber" and columns will be displayed in this order.</p>
<p>Is it possible to change dynamically column order?</p>
<p>What is the best way to do this?</p>
<p> </p>
<p>Thank you in advance,</p>
<p> </p>
<p>Julien</p>
Find more posts tagged with
Comments
pricher
<p>HI,</p>
<p> </p>
<p>Assuming your parameter is named pSort, select the table component, go to the Sorting tab and enter the Expression row[params["pSort"].value].</p>
<p> </p>
<p>
Matthew L.
<p>This can be a bit tricky, however modifying a previous example that creates <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/24254-creating-column-dynamically/?p=132987'>dynamic
tables</a> we can arrange the order of the columns based on their input order in a comma separated parameter input.</p>
<p> </p>
<p>Please look over this modified design and let me know if you have any questions about it.</p>
<p> </p>
pricher
<p>ooops, I realize that I totally misread the question.... Matthew's post is the one to keep!!!</p>
<p> </p>
<p>Sorry for that,</p>
<p> </p>
<p>P.</p>
julienemixis
<p>Thanks for your answers, i will try it.</p>
julienemixis
<p>Hello Matthew,</p>
<p> </p>
<p>I tried your code and it works fine but the problem is that I have to make a lot a things in my reports (dynamic group and order, hidding columns with the same order column param, hidding row in xsl output, custom background...) and i have more or less 20 reports to write, with dead line it's not possible to write all of them dynamically..</p>
<p> </p>
<p>Is there an other way to change order after report generation?</p>
<p> </p>
<p>Thanks for your Help.</p>
<p> </p>
<p>Julien</p>
Matthew L.
<p>If you are using the Professional version of BIRT, it includes an Interactive Viewer (IV) which you could hook and arrange the columns after generation. </p>
<p>However this technique would only work for the IV web viewer and the column order would not be effected for outputs such as PDF, DOC, XLS, etc...</p>
<p> </p>
<p>Also note that if you are dynamically changing lots of properties (groupings, column order, hidden rows, background colors, etc) some of these options are only changeable during the table's build state (beforeFactory).</p>
<p> </p>
<p>It really depends on the requirements of the final output.</p>
PaulCooper
<p>Matthew,</p>
<p> </p>
<p>You could split the comma separate list of fields into an array</p>
<p> </p>
<p>(Report Initialize event)</p>
<pre class="_prettyXprint">
columnArray = params["columnSortOrder"].split(","); </pre>
<p>and then use in the data fields in tables <em>row[columnArray[0]]</em>, <em>row[columnArray[1]]</em>, etc.</p>
<p> </p>
<p>You would need some sort of lookup for column headers too such as:</p>
<p> </p>
<p>(Report Initialize event)</p>
<pre class="_prettyXprint">
columns = ["vehicle", "reference", "platenumber"];
titles = ["Vehicle", "Reference", "Plate Number"]
function columnTitleLookup(column)
{
try
{
return titles[columns.indexOf(column)];
}
catch (e)
{
return "";
}
}</pre>
<p>and then use in the column header data field <em>columnTitleLookup(columnArray[0])</em>, <em>columnTitleLookup(columnArray[1])</em>, etc.</p>
<p> </p>
<p>Paul</p>