Crosstab column order

This public forum is for user-to-user discussions of ASP Report Maker. Note that this is not support forum.

Crosstab column order

Postby ready4data » Thu Sep 22, 2016 2:44 am

The dynamic columns are sorted alphabetically. Is there a way to specify the column order through server events or other means?

Thanks,
Scott
ready4data
 
Posts: 276
Joined: Mon Nov 19, 2012 8:24 pm

Re: Crosstab column order

Postby motfs » Thu Sep 22, 2016 12:55 pm

Only ascending or descending order is provided. If you need to move the column, use Startup Script to move the column. Google "jQuery move column" to find a solution.
motfs
 
Posts: 710
Joined: Tue Sep 08, 2015 4:55 pm

Re: Crosstab column order

Postby ready4data » Mon Sep 26, 2016 11:56 pm

The following code will let you change the order of the columns in the crosstab report.
$(function() { //Change the order of the columns
jQuery.each($("table tr"), function() {
$(this).children(":eq(6)").after($(this).children(":eq(5)")); //Moves column 5 after 6(0 based)
$(this).children(":eq(7)").after($(this).children(":eq(10)")); //Moves column 10 after 7
});
});
But...
Being the crosstab is inherently dynamic, if you make a filter selection that doesn't include some of your columns, they will be out of order.
I came up with another solution. I have less than 26 columns so I created a table with the column header name and a sort letter (a-z) field.
This table updates(query) the report source by adding the appropriate letter before the column header name. Eg. Oranges becomes aOranges, Pear becomes bPear, etc.
The report automatically sorts by the first letter so your columns are now in order. What if the report user asks you what a bPear or a fLemon is?
Well, there is one report modification you need to make in the generated code.
Find the section <!-- Dynamic columns begin --> in the report and change:
<reportName>.SummaryCurrentValue(iy-1) = <reportName>.Col(iy).Caption
to
<reportName>.SummaryCurrentValue(iy-1) = Mid(<reportName>.Col(iy).Caption,2,20) 'Increase the 20 if you have long column names or use Len()
This will hide the first letter that is used for sorting.

Scott
ready4data
 
Posts: 276
Joined: Mon Nov 19, 2012 8:24 pm


Return to General Discussion (ASP Report Maker)