Telerik Forums
Reporting Forum
2 answers
478 views
I'm attempting to adjust the column width programatically and from other forum posts I've read that there is allot involved.

I can Hide Column content on ItemDataBound, but I cannot collapse the width.
Using JustCompile and the debugger I believe I'm setting all the proper widths, but I cannot get it to collapse.

below is my code.
Can you provide any insight on the events between ItemDataBound and rendering and if there is an event between where I can adjust these values.  
public static void RemoveColumns(this Telerik.Reporting.Table tableDef, params int[] columns)
{
    /*
    var colGroups = Flatten(tableDef.ColumnGroups).ToList();
 
    foreach (int column in columns)
    {
        // colGroups[column].Visible = false; // Object not found Error in binding
        colGroups[column].Filters.Clear();
        colGroups[column].Filters.Add(new Telerik.Reporting.Filter("=1", Telerik.Reporting.FilterOperator.Equal, "=0")); // Object not found Error in binding
    }
 
    return;
    */
 
    var tableBody = tableDef.Body;
    var tableCells = tableBody.Where(x => x.ReportItem != null).ToList();
    var zero = Telerik.Reporting.Drawing.Unit.Inch(0);
 
 
    foreach (int colIndex in columns.OrderByDescending(x => x))
    {
        tableBody.Columns[colIndex].Width = zero;
 
        // shrink all cell.reportItem(s)
        foreach (var cell in tableCells.Where(x => x.ColumnIndex == colIndex))
        {
            // cell.ReportItem.Visible = false; throws error during Binding
            cell.ReportItem.Width = zero;
                     
            if (cell.ReportItem is Telerik.Reporting.TextItemBase)
                ((Telerik.Reporting.TextItemBase)cell.ReportItem).CanGrow = false;
        }
    }
}
 
         
/// <summary>
/// ItemDataBound, Remove columns by settings its content Visibility
/// </summary>
/// <param name="table"></param>
/// <param name="columns"></param>
public static void RemoveColumns(this Telerik.Reporting.Processing.Table table, params int[] columns)
{
    RemoveColumns((Telerik.Reporting.Table)table.ItemDefinition, columns);
    var zero = Telerik.Reporting.Drawing.Unit.Inch(0);
 
             
    foreach (var textbox in table.TableCells(x => columns.Contains(x.ColumnIndex)).OfType<Telerik.Reporting.Processing.TextBox>())
    {
        // textbox.Visible = false; // Doesn't collapse column
        textbox.Width = zero;
        textbox.Value = string.Empty;
 
        TextboxCanGrowProperty.SetValue(textbox, false, null);
    }
 
    foreach (var column in table.Columns.Where(x => columns.Contains(x.Index)))
    {
        TableColumnWidthProperty.SetValue(column, 0D, null);
    }
 
}
 
 
private static IEnumerable<Telerik.Reporting.Processing.ITableCell> TableCells(this Telerik.Reporting.Processing.Table table, Func<Telerik.Reporting.Processing.ITableCell, bool> predicate = null)
{
    Telerik.Reporting.Processing.ITableCell cell;
    int colCount = table.Columns.Count;
    int rowCount = table.Rows.Count;
 
    for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
    {
        for (int colIndex = 0; colIndex < colCount; colIndex = colIndex + cell.ColumnSpan)
        {
            cell = table.GetCell(rowIndex, colIndex);
 
            if (predicate == null || predicate(cell))
                yield return cell;
        }
    }
}
 
public static IEnumerable<Telerik.Reporting.TableGroup> Flatten(this IEnumerable<Telerik.Reporting.TableGroup> collection)
{
    foreach (var group in collection)
    {
        yield return group;
 
        foreach (var subGroup in Flatten(group.ChildGroups))
            yield return subGroup;
    }
}
 
private static PropertyInfo _tablecolumnWidthProperty = null;
public static PropertyInfo TableColumnWidthProperty
{
    get
    {
        if (_tablecolumnWidthProperty == null)
            _tablecolumnWidthProperty = typeof(Telerik.Reporting.Processing.TableColumn).GetProperty("Width", BindingFlags.Instance | BindingFlags.NonPublic);
 
        return _tablecolumnWidthProperty;
    }
}
 
private static PropertyInfo _textboxCanGrowProperty = null;
public static PropertyInfo TextboxCanGrowProperty
{
    get
    {
        if (_textboxCanGrowProperty == null)
            _textboxCanGrowProperty = typeof(Telerik.Reporting.Processing.TextItemBase).GetProperty("CanGrow", BindingFlags.Instance | BindingFlags.NonPublic);
 
        return _textboxCanGrowProperty;
    }
}


Thanks
Steve
Steven
Top achievements
Rank 1
 answered on 27 Dec 2012
5 answers
852 views
I have a crosstab report which shows stats for permits submitted over a 6 year period. I have them broken down by several different parameters. I have the latest year column set to be shaded a dark grey and the 2nd, 4th, and 6th years shaded a light grey. I sort them into the years based on a date permit was approved. My problem is that if here is no permits that match one of the categories it doesn't shade that box. It doesn't make the report look good with breaks in the shading. I have it filling 0's for the null cells by checking for nulls but it still doesn't shade the cells.

Any help would be greatly appreciated.
IvanY
Telerik team
 answered on 27 Dec 2012
3 answers
365 views
Hello,

We are running on an older version of the Reporting  2011 Q2 but need to user the native header features.

I have set the device information header variables (they work fine for grid lines) to true for UseNativePageHeader but the report is rendered with the header at the top of the page basically ignoring the variable.

Is there anything I am missing?
Petio Petkov
Telerik team
 answered on 27 Dec 2012
3 answers
1.1K+ views
Hi Telerik Team,

I have a table in one of my reports and I now want to change the background color of specific rows, depending of data which is contained in the row.

How can I achieve that?

Thanks in advance.
IvanY
Telerik team
 answered on 27 Dec 2012
1 answer
198 views
Hi Telerik Team
I need know if can apply ReportBook for files .trdx(without classes), this because  i have some subreports and i need export to excel, every report in every sheet of one excel file

This is possible?

Thanks
Stef
Telerik team
 answered on 27 Dec 2012
1 answer
137 views
When i Upload data in  Silverlight ReportViewer 
      Error show:-  Report Viewer not display more then 1000 record only show first 1000 record.

Please its urgent!
Hadib Ahmabi
Top achievements
Rank 1
 answered on 27 Dec 2012
1 answer
69 views
RE: http://www.telerik.com/products/reporting/data-presentation-and-analysis.aspx

We are internally evaluating Telerik Reporting. Looks like to use/show charts (bar, graph, pie, etc.) we would need to also buy RAD controls. Is that a right assessment?
Petio Petkov
Telerik team
 answered on 27 Dec 2012
4 answers
240 views
My report is not bound to a DataSource, but in the PageHeaderSection my Textbox_ItemDataBinding event keeps getting called in an infinite loop.

I have a pretty complex table in a ReportHeaderSection that is bound, but stepping through the debugger the Table finishes binding its dataset without any issues.  I originally had it in the detailSection but changed it in my debugging efforts.



How can I determine what is causing the infinite loop in the PageHeaderSection when the processing is done in the ReportEngine.


Steve
Stef
Telerik team
 answered on 27 Dec 2012
1 answer
404 views
I am interested in telerik reporting. However, my requirement is that my data source needs to be json data either coming from a web service or mongodb. Is it is supported? If not, is it in the pipeline? When can we expect such feature.
Hadib Ahmabi
Top achievements
Rank 1
 answered on 27 Dec 2012
2 answers
86 views
Hi,

I've seen permutations of this question come up but I haven't seen a response that has clicked for me.  I have a datasource in my report that returns data with these columns:

emp_id, fname, lname, client_name, carrier_plan_title, effective_date, client_cost_pay_freq
1, Jon, Smith, Acme Group, HMO, 01/01/2012, 400.00
1, Jon, Smith, Acme Group, Dental, 01/01/2012, 200.00
2, Lindsey, Buckingham, Acme Group, PPO, 03/01/2012, 150.00

What I'm trying do is group the information by the 'emp_id' column and then within the details section of the report, display a table that outputs the carrier_plan_title, effective_date and client_cost_pay_freq per employee.  I have figured out how to group by emp_id, but haven't figured out how to display each individual carrier_plan_title, effective_date and client_cost_pay_freq per employee.  I don't think I'm quite getting how the group and details sections and tables actually work.  attached is a screen shot of what I have.

Brett
Brett
Top achievements
Rank 1
 answered on 26 Dec 2012
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?