This is a migrated thread and some comments may be shown as answers.

Adjusting size of crosstab at runtime

5 Answers 148 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sivam
Top achievements
Rank 1
Sivam asked on 14 Jun 2010, 03:40 PM
Hi,

How to adjust the size of the crosstab at runtime?  The total width of the crosstab should be fixed, but the size of textboxes inside should be adjusted according to the number of columns. How can i achieve this?

Thanks

5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 15 Jun 2010, 01:36 PM
Hi Sivam,

As you probably know, the TextBox item can grow only vertically, thus in a CrossTab, the width of the textboxes is defined during design time and the same size is used for all columns independently of their number. Since those columns are generated dynamically during runtime, there is no way to adjust the size of a particular column only.
A possible solution for your scenario would be to generate the CrossTab dynamically and specify the widths of its items based on your datasource.

Sincerely yours,
Steve
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Sivam
Top achievements
Rank 1
answered on 15 Jun 2010, 02:47 PM
Hi Steve,

Thanks for the response. Is there any sample on generating crosstab dynamically?

Thanks
0
Steve
Telerik team
answered on 16 Jun 2010, 06:13 PM
Hello Sivam,

I've attached a sample project for your convenience.

Best wishes,
Steve
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Sivam
Top achievements
Rank 1
answered on 21 Jun 2010, 07:13 AM
Thanks Steve for the sample project.

I found an work-around to achieve my requirement. I'm not sure my logic is efficient or not. But it works.

int cnt = dt1.Rows.Count;  
Telerik.Reporting.TableGroup tblgrp = new TableGroup();  
tblgrp = (Telerik.Reporting.TableGroup)Crosstab1.ColumnGroups[0];  
                switch (cnt)  
                {  
                    case 1:  
                        tblgrp.ReportItem.Size = new SizeU(Unit.Cm(4.8), Unit.Cm(1));  
                        this.textBox4.Size = new SizeU(Unit.Cm(12.8), Unit.Cm(1));  
                        break;  
                    case 2:  
                        tblgrp.ReportItem.Size = new SizeU(Unit.Cm(4.4), Unit.Cm(1));  
                        this.textBox4.Size = new SizeU(Unit.Cm(8.8), Unit.Cm(1));  
                        break;  
                    case 3:  
                        tblgrp.ReportItem.Size = new SizeU(Unit.Cm(3.8), Unit.Cm(1));  
                        this.textBox4.Size = new SizeU(Unit.Cm(5.8), Unit.Cm(1));  
                        break;  
                    case 4:  
                        tblgrp.ReportItem.Size = new SizeU(Unit.Cm(2.8), Unit.Cm(1));  
                        this.textBox4.Size = new SizeU(Unit.Cm(5.8), Unit.Cm(1));  
                        break;  
                    case 5:  
                        tblgrp.ReportItem.Size = new SizeU(Unit.Cm(2.4), Unit.Cm(1));  
                        this.textBox4.Size = new SizeU(Unit.Cm(5.4), Unit.Cm(1));  
                        break;  
                }             

Depending on the no. of columns, i set the width. textbox4 is the RowGroup textbox.
0
Gurinder
Top achievements
Rank 1
answered on 02 Jan 2018, 11:35 AM

Hi Steve,

Do you have latest code for it. I tried your code, upgraded version, resolved resx issue. During "Preview", in debug mode, it shows data in Table[0], assigns datasource. After that, UI displays message "object ref is not set".

 

Thanks

Guri

Tags
General Discussions
Asked by
Sivam
Top achievements
Rank 1
Answers by
Steve
Telerik team
Sivam
Top achievements
Rank 1
Gurinder
Top achievements
Rank 1
Share this question
or