Resize merged column when columns below are hidden

5 Answers 41 Views
Conditional Formatting General Discussions Report Designer (standalone) Table
Marvin
Top achievements
Rank 2
Veteran
Iron
Marvin asked on 13 Jul 2021, 04:03 PM | edited on 13 Jul 2021, 04:14 PM

I have a header column in a table that is merged across three columns below. I conditionally hide the middle column and want to shrink the width of the merged column to the size of the remaining two columns. 

I've tried multiple ways to do this and haven't been able to get an answer.

See attached examples. I want to hide the Cost Column on certain conditions, and have the width of "Out" be the size of Quantity + Price.

 

5 Answers, 1 is accepted

Sort by
1
Accepted
Dimitar
Telerik team
answered on 26 Jul 2021, 12:56 PM

Hello Marvin,

Thank you for the provided report.

The table's Width is controlled by the sizing of its body, the table columns, shrinking the columns would also shrink the table itself. Unfortunately, the master header spanning all over the table prevents it from actually shrinking, and thus when you hide the second column, the third simply takes up its place. To achieve the desired result, we need to be a little hacky in this case. Set the ColumnWidth to 11px(this is as low as we can go, see Error "Each table row and column maintains a minimum size, resulting in a minimum table size of {Width=10px, Height=10px}" in Report Designer). Now, when we hide the second column, the third will still take up its space but now it will be just a little more than 2in. However, when the second column is not hidden, the 3rd column will be really really small with this setting for the ColumnWidth, so set a binding to textBox4's Width to the following expression:

= "1in"

This will ensure that the third column has adequate width even when the second column is not hidden.

I am attaching back the modified report to my reply, please let me know if you have any other questions or need further help.

Regards,
Dimitar
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
0
Marvin
Top achievements
Rank 2
Veteran
Iron
answered on 16 Jul 2021, 03:11 PM

I've updated the  a different set of screen shots.

I have three columns of information that I want to see at times, and only two based on a condition.

In the current screen shots you can see that in the Design. 

Notice that when I hide column2 or column3, the "Header for all columns" doesn't resize with them. I've tried binding the width, but haven't been successful. Not sure what to property to bind.

Do I resize the whole table, or can I resize "Header for all columns"? Not sure I understand the syntax used for resizing the width.

Thanks,

Marvin

 

0
Dimitar
Telerik team
answered on 21 Jul 2021, 01:55 PM

Hello Marvin,

Thank you for the provided pictures.

In order to bind to a certain column's width, you need to select the column itself and not the cells in it, see the attached PNG file for an example.

Then you add a binding to the Width property of that column and you set the value of it in the expression since you want to shrink the column only at certain times, you will probably need to write some logic in the expression and return different values based on condition, a sample condition, and return values are present in the attached PNG.

I have attached a sample report and a short video of me creating the bindings to the columns and displaying the effects of those bindings at runtime.

If you will need further help, please attach the report to your next reply alongside some sample data, preferably in CSV or JSON format, and I will investigate the report locally.

I look forward to receiving an update from you.

Regards,
Dimitar
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
0
Marvin
Top achievements
Rank 2
Veteran
Iron
answered on 21 Jul 2021, 02:49 PM

Thanks for your reply, Dimitar.

Please find the report attached.

I tried conditionally resizing both the table and the column, but with no success.

If HideColumn2 = True then I want TextBox7 to be "Width = 2in" rather than 3in.

-1
Dimitar
Telerik team
answered on 16 Jul 2021, 11:04 AM

Hello Marvin,

Thank you for the provided pictures.

If I understand correctly, you are trying to conditionally hide a column of the table and you want this to result in the table shrinking, is that correct?

Based on the Design image, I cannot decide whether this Out column is actually a separate table column or it is inside a single table column that has been split into three "sub-columns" so to say.

If it is a separate table column, then the reason for the table not shrinking is probably that you are applying the conditional formatting to the table's cell and not the column itself, it is very important to select the column and then apply the conditional formatting to it. If things are done correctly, the table will shrink when that column is no longer visible. I have attached a short video demonstrating how to select a table column and how to apply conditional formatting to it. The sample report that I made in the video is also attached.

Note that the report that is attached uses the latest report definition schema and will not be able to open by older report designers. If you have an older version, you may edit the definition.xml to use a schema that your report designer can open. For more information, see How to: Identify the report definition schema version

If it is the second case, the column has three "sub-columns", you will need to create a binding to this column's width where it is a certain size when the condition, for one of the sub-columns to become invisible is met, and then another size when all sub-columns are visible. For this, you may use the IIf() logical function.

Please let me know if you have any other questions or need further help.

Regards,
Dimitar
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
Tags
Conditional Formatting General Discussions Report Designer (standalone) Table
Asked by
Marvin
Top achievements
Rank 2
Veteran
Iron
Answers by
Dimitar
Telerik team
Marvin
Top achievements
Rank 2
Veteran
Iron
Share this question
or