how to render dynamic columns

Stimulsoft Reports.NET discussion
Post Reply
fjaweihyafie
Posts: 22
Joined: Wed Feb 06, 2013 6:12 am

how to render dynamic columns

Post by fjaweihyafie »

now I have a UI like:(□ means checkbox)
□ column 1
□ column 2
□ column 3

when cilent check the colums (multi-selection) , such as column1 and column2 are checked , then my datasource will generate data of column1 and column2 , if column3 is checked , my datasource will generate data of column3 , the columns in datasource are depended on the UI which client checked .
My question is how can I make such a requirement in mrt . When I design in mrt , the layout is static and the data will be fill in the place I assigned . I hope the columns will be large enough with the page size ,whethe it is one column or more colums .
Thanks!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: how to render dynamic columns

Post by Alex K. »

Hello,

Please see the sample report in the attachment.

Thank you.
Attachments
SelectingColumns.mrt
(47.02 KiB) Downloaded 428 times
fjaweihyafie
Posts: 22
Joined: Wed Feb 06, 2013 6:12 am

Re: how to render dynamic columns

Post by fjaweihyafie »

Aleksey wrote:Hello,

Please see the sample report in the attachment.

Thank you.

yep ! That's it , thanks very much ! :lol:
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: how to render dynamic columns

Post by Alex K. »

Hello,

We are always glad to help you!
Let us know if you need any additional help.
fjaweihyafie
Posts: 22
Joined: Wed Feb 06, 2013 6:12 am

Re: how to render dynamic columns

Post by fjaweihyafie »

Hi , Thanks for your help . It did work , but I had a problem that when then client get reports from UI (windows from created by mrt designer) it wroks well ( I added the code in click event as you suggested .) But I still had a utility to run report from promt (cmd.exe) , but in this condition it does not work . I added the code control the column' enable in beginrender (Report) and click (botton) both , I find the code occur in before render firest then click ,but it did not work in click event to change the enable property.
such as

Code: Select all

public void Report_BeginRender(object sender, System.EventArgs e)
        {
            string[] Period = ReportingPeriod.Split(new char[]{','});
foreach(string s in Period )
{
	switch (s)
	{
		case "0" :
				lblDaily.Enabled = true ;
				txtDaily.Enabled = true ;
				break;
		case "1" :
				lblMTD.Enabled = true;
				txtMTD.Enabled = true;
				break;
		case "2" :
				lblQTD.Enabled = true;
				txtQTD.Enabled = true;
				break;
		case "3" :
				lblYTD.Enabled = true;
				txtYTD.Enabled = true;
				break;
		case "4" :
				lblLTD.Enabled = true;
				txtLTD.Enabled = true;
				break;
	}
}

double width = 0;
int i = 0;

foreach (StiComponent comp in DataBand1.Components)
{
	if (comp.Enabled)
	{
		//width += comp.Width;  
		i++;
	}  
}

double factor = (DataBand1.Width - ( i - 1 ) * 0.1) / i ;

i = 0;
foreach (StiComponent comp in DataBand1.Components)
{
	if (comp.Enabled)
	{
		comp.Width = factor;
		comp.Left = i  * 0.1 +  i  * factor;
		i++;
	}	
}

i = 0;
foreach (StiComponent comp in HeaderBand1.Components)
{
	if (comp.Enabled)
	{
		comp.Width = factor;
		comp.Left = i  * 0.1 +  i  * factor;
		i++;
	}
}
;
        }

Code: Select all

 public void btnOk_Click(object sender, System.EventArgs e)
        {
            ReportingPeriod = String.Empty;
if( ckbDaily.Checked )
{
	ReportingPeriod +="0,";
}
if( ckbMTD.Checked )
{
	ReportingPeriod +="1,";
}
if( ckbQTD.Checked )
{
	ReportingPeriod +="2,";
}
if( ckbYTD.Checked )
{
	ReportingPeriod +="3,";
}
if( ckbLTD.Checked )
{
	ReportingPeriod +="4,";
}



if( ReportingPeriod.LastIndexOf(",") == ReportingPeriod.Length -1 )
{
	ReportingPeriod = ReportingPeriod.Substring(0, ReportingPeriod.Length-1);
}

EffectiveDate = dtpEffDate.Value;

ContentDataSource.ConnectOnStart = true;

string[] Period = ReportingPeriod.Split(new char[]{','});
foreach(string s in Period )
{
	switch (s)
	{
		case "0" :
				lblDaily.Enabled = true ;
				txtDaily.Enabled = true ;
				break;
		case "1" :
				lblMTD.Enabled = true;
				txtMTD.Enabled = true;
				break;
		case "2" :
				lblQTD.Enabled = true;
				txtQTD.Enabled = true;
				break;
		case "3" :
				lblYTD.Enabled = true;
				txtYTD.Enabled = true;
				break;
		case "4" :
				lblLTD.Enabled = true;
				txtLTD.Enabled = true;
				break;
	}
}

double width = 0;
int i = 0;

foreach (StiComponent comp in DataBand1.Components)
{
	if (comp.Enabled)
	{
		//width += comp.Width;  
		i++;
	}  
}

double factor = (DataBand1.Width - ( i - 1 ) * 0.1) / i ;

i = 0;
foreach (StiComponent comp in DataBand1.Components)
{
	if (comp.Enabled)
	{
		comp.Width = factor;
comp.Left = i  * 0.1 +  i  * factor;
		i++;
	}	
}

i = 0;
foreach (StiComponent comp in HeaderBand1.Components)
{
	if (comp.Enabled)
	{
		comp.Width = factor;
comp.Left = i  * 0.1 +  i  * factor;
		i++;
	}
}



;
        }
I found only the Report_BeginRender work , the btnOk_Click worked but did not change the controls enable . If I just add the code in btnOK_Click when I use ultility I can get the result I need ....
How can I make it both affect or after Report_BeginRender and btnOk_Click ,the btnOK_Click will change the enable also.
Thanks .
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: how to render dynamic columns

Post by Alex K. »

Hello,

Can you please send us a sample project which reproduce the issue for analysis.

Thank you.
Post Reply