How to sort use meth in report's form?

Stimulsoft Reports.NET discussion
RickyHuang
Posts: 68
Joined: Tue Feb 09, 2010 3:16 am
Location: Taiwan

How to sort use meth in report's form?

Post by RickyHuang »

this is my code in report form's button click event
string var;
var = "";
foreach (StiRadioButtonControl obj in PanelControl2.Components)
{
if(obj.Checked)
{
var = obj.Name;
break;
}
}

if (RadioButtonControl1.Checked)
{DataCS210.Sort = new System.String[] {
"ASC",
var};
}
else
{DataCS210.Sort = new System.String[] {
"DESC",
var};
}
obj.Name is my DataSource.DataColumn's Name

But now,I want to sort by meth,it's like ds.A + ds.B

If i use the meth in sort tab in report's databand,it can work,but use it in form's button event,it cant work.

How to do it?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How to sort use meth in report's form?

Post by Alex K. »

Hello,

If "var" is the calculated column for your data sources then it will not be possible to do this because for calculated columns the sorting should be added before compilation of reports. If these are not calculated columns then, please see a report sample how to do this.

Thank you.
Attachments
559.Sample Report.mrt
(16.66 KiB) Downloaded 302 times
RickyHuang
Posts: 68
Joined: Tue Feb 09, 2010 3:16 am
Location: Taiwan

How to sort use meth in report's form?

Post by RickyHuang »

If it is not a column,it just is a function,can it work ?

like this
DataCS210.Sort = new System.String[] {
"ASC",
"ds.A + ds.B"};
or

next realease will add this feature?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How to sort use meth in report's form?

Post by Alex K. »

Hello,

If we understand you task correctly you can use:
DataCS210.Sort = new System.String[] {
"ASC",
"ds.A",
"ASC",
"ds.B"};
Thank you.
RickyHuang
Posts: 68
Joined: Tue Feb 09, 2010 3:16 am
Location: Taiwan

How to sort use meth in report's form?

Post by RickyHuang »

:cry:

ex:

Coke----FrenchFries----Total
100------50--------------150

I want sort by total,and toal not is a calculated column ,I use this function in 『Coke + FrenchFires』to sort it in report in sort tab,it can work...

can i use it in report's form,too?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How to sort use meth in report's form?

Post by Alex K. »

Hello,

Please see the sample report in attachment.

Thank you.
Attachments
560.Sample Report.mrt
(24.97 KiB) Downloaded 357 times
RickyHuang
Posts: 68
Joined: Tue Feb 09, 2010 3:16 am
Location: Taiwan

How to sort use meth in report's form?

Post by RickyHuang »

thanks ,I test it in my report, but it's not work

1. It's not work <-----I want sort like 『iif(true,ds.A*10,ds.A/10)』
DataCS210.Sort = new System.String[] {
"ASC",
"ds.A * 10"};
2. It's not work
DataCS210.Sort = new System.String[] {
"ASC",
"ds.A"};
3.1. It's work
DataCS210.Sort = new System.String[] {
"ASC",
"A"};
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How to sort use meth in report's form?

Post by Alex K. »

Hello,

You need add two metods:
public class Report : Stimulsoft.Report.StiReport
{
public object GetData_Sort1()
{
return ds.A * 10;
}

public object GetData_Sort2()
{
return ds.A / 10;
}

public Report()
{
this.InitializeComponent();
}
#region StiReport Designer generated code - do not modify
......
and in report form's button click event:
string var;
var = "";
foreach (StiRadioButtonControl obj in PanelControl2.Components)
{
if(obj.Checked)
{
var = obj.Name;
break;
}
}

if (RadioButtonControl1.Checked)
{DataCS210.Sort = new System.String[] {
"ASC",
"{GetData_Sort1}"};
}
else
{DataCS210.Sort = new System.String[] {
"DESC",
"{GetData_Sort2}"};
}
Thank you.
Attachments
561.Sample Report.mrt
(25.21 KiB) Downloaded 463 times
RickyHuang
Posts: 68
Joined: Tue Feb 09, 2010 3:16 am
Location: Taiwan

How to sort use meth in report's form?

Post by RickyHuang »

I know,i had view the code page.

but i dont know how to key in

thanks for your sample

now i know how to do it.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How to sort use meth in report's form?

Post by Alex K. »

Hello,

Let us know if you need any additional help.

Thank you.
Post Reply