Telerik.Reporting.Processing.TableCell removed in the new version ! And now ?

12 posts, 0 answers
  1. Marco Piumi
    Marco Piumi avatar
    29 posts
    Member since:
    Apr 2005

    Posted 19 Jul 2010 Link to this post

    The class Telerik.Reporting.Processing.TableCell was removed in the new version of Telerik Reporting !!
    Now I don't know how to Access report fields from a Table item.
    The example in documentation is :

    private void tableTextBox_ItemDataBinding(object sender, EventArgs eventArgs)
    {
        //get the textbox from the sender object            
        Processing.TextBox textBox = (Processing.TextBox)sender;
        //get the corresponding tableCell in which the textbox is located
        Processing.TableCell tableCell = (Processing.TableCell)textBox.Parent;
        //get the table object
        Processing.Table table = (Processing.Table)tableCell.Parent;
        //get the detail section
        Processing.DetailSection detail = (Processing.DetailSection)table.Parent;
        //get the raw value from the Report datasource directly
        textBox.Value = detail.DataObject["Data"];
    }

    But now this is not possible !!!

    And now ????

    My code don't work more !!!!!

    Thank you !
  2. Tonci Kucic
    Tonci Kucic avatar
    4 posts
    Member since:
    Feb 2009

    Posted 21 Jul 2010 Link to this post

    Same problem here...
    I have to iterate TableCells in each row....
    How to accomplish that now?
  3. DevCraft banner
  4. Svetoslav
    Admin
    Svetoslav avatar
    649 posts

    Posted 21 Jul 2010 Link to this post

    Hello guys,

    In order to improve the performance of the Table report item, as of version Q2 2010 (release notes) the TableCell item was removed from the processing model.

    Anyway there is nothing to worry as this item was only used as a placeholder and now the item hierarchy is even simpler. In Q2 instead of cells, the table contains only the usual report items (TextBox, PictureBox, etc).

    This section related to Marco's code snippet means that now textBox.Parent returns the Table item instead of the obsolete TableCell:

    //get the textbox from the sender object           
    Processing.TextBox textBox = (Processing.TextBox)sender;
    //get the table object
    Processing.Table table = (Processing.Table)textBox.Parent;
    //get the detail section
    Processing.DetailSection detail = (Processing.DetailSection)table.Parent;
    //get the raw value from the Report datasource directly
    textBox.Value = detail.DataObject["Data"];

    In Marco's particular case a similar result can be achieved if you set the value of this TextBox item to the expression:

    =ReportItem.Parent.DataObject.Data

    that will return exactly the same result.


    Best wishes,
    Svetoslav
    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
  5. Marco Piumi
    Marco Piumi avatar
    29 posts
    Member since:
    Apr 2005

    Posted 21 Jul 2010 Link to this post

    Thank you for the solution.

    But I have another problem : how to get the control's index row in the table !!!

    Before i wrote this code :

    int index = tableCell.RowIndex,

    But now the object TableCell don't exists more !!

    Thanks
  6. Svetoslav
    Admin
    Svetoslav avatar
    649 posts

    Posted 22 Jul 2010 Link to this post

    Hello guys,

    As the Table item is supposed to display dynamic data - that is the rows, columns and cells of the result table depends entirely on the table definition including its row and column group hierarchies and cell expressions. The Table item sports extremely powerful data binding capabilities that almost completely override the need for additional manipulations so we will appreciate if you can share with us your particular cases that demand such cell iteration.

    Regards,
    Svetoslav
    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
  7. Marco Piumi
    Marco Piumi avatar
    29 posts
    Member since:
    Apr 2005

    Posted 22 Jul 2010 Link to this post

    Here the code that worked previously.
    I need to confront row values with previous row of the table !!!
    In second function, I need to format a row by code in a specific case. The designer does not allow to format an entire row with same rule !
     
    private void txtSubCommessaME_ItemDataBinding(object sender, EventArgs e)
    {
        Telerik.Reporting.Processing.TextBox txtsubcommessa = (Telerik.Reporting.Processing.TextBox)sender;
        Telerik.Reporting.Processing.TableCell tableCell = (Telerik.Reporting.Processing.TableCell)txtsubcommessa.Parent;
        int index = tableCell.RowIndex;
        if (index > 2)
        {
            Telerik.Reporting.Processing.Table table = (Telerik.Reporting.Processing.Table)tableCell.Parent;
            DataTable dt = table.DataSource as DataTable;
            DataRow dr = dt.Rows[index - 3];
            DataRow dr1 = dt.Rows[index - 2];
            if (dr["SubCommessa"].ToString() == dr1["SubCommessa"].ToString()) txtsubcommessa.Value = "";
        }
    }
    private void txtCodice_ItemDataBinding(object sender, EventArgs e)
    {
        Telerik.Reporting.Processing.TextBox txtcodice = (Telerik.Reporting.Processing.TextBox)sender;
        Telerik.Reporting.Processing.TableCell tableCell = (Telerik.Reporting.Processing.TableCell)txtcodice.Parent;
        int index = tableCell.Index;
        if (index > 0)
        {
            Telerik.Reporting.Processing.Table table = (Telerik.Reporting.Processing.Table)tableCell.Parent;
            DataView dv = table.DataSource as DataView;
            DataRow dr = dv.Table.Rows[index - 1];
            if (Convert.ToInt32(dr["ID_SubCommessa"]) != 0)
            {
                foreach (Telerik.Reporting.Processing.ReportItem tc in table.Rows[index].)
                {
                    tc.Style.Font.Bold = true;
                }
            }
            if (Convert.ToInt32(dr["ID_Attivita"]) != 0)
            {
                foreach (Telerik.Reporting.Processing.TableCell tc in table.Rows[index].Cells)
                {
                    tc.Style.Font.Italic = true;
                }
            }
        }
    }

    This is the reason for indentify a row index of the examining control !

    Thanks
  8. Svetoslav
    Admin
    Svetoslav avatar
    649 posts

    Posted 28 Jul 2010 Link to this post

    Hello Marco Piumi,

    Although I'm not sure how the given code examples work and what they are suppose to do (there are some incorrect and confusing statements in your code that makes us think it is not a real working code) but looks like you don't actually need this table cell objects.

    For the 1st event handler a possible solution (recommended) is to use an user function like this:

    public static string GettxtSubCommessaMEValue(string value, int rowIndex)
    {
        if (rowIndex > 2)
        {
            ..
            return string.Empty;
        }
         
        return value;
    }

    and use it for the txtSubCommessaME like this:

    txtSubCommessaME.Value = "=GettxtSubCommessaMEValue(Fields.SubCommessaME, RowNumber())";

    Regarding the 2nd example I would recommend using a conditional formatting rule rather than iterating through the cells.

    Another very important thing you should always consider is that your data should be prepared according to your needs, so it is common to add additional fields that will simplify your tasks of displaying and formatting the data.

    Once again please note that we are not familiar with your particular requirements and we can only guess what these code snippets do.

    Best wishes,
    Svetoslav
    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
  9. VanirDev
    VanirDev avatar
    9 posts
    Member since:
    Nov 2008

    Posted 28 Jul 2010 Link to this post

    I would like to apply different format based on data in another cell of the same row. 
    For example:
    If a field value of the same row equals 1 then use {0:#0.00} otherwise {0:$#,##0;($#,##0); }
    Could you tell me how to achieve that?

    Thank you,
    Pawel
  10. VanirDev
    VanirDev avatar
    9 posts
    Member since:
    Nov 2008

    Posted 29 Jul 2010 Link to this post

    I solved it in the following way:
    private void txtYTDActual_ItemDataBound(object sender, EventArgs e)
    {
        this.SetTextBoxFormat((Telerik.Reporting.Processing.TextBox)sender);
    }
    private void SetTextBoxFormat(Processing.TextBox textBox)
    {
        string name = (string)textBox.DataObject["Name"];
        if (name == "Average Multiplier")
            textBox.Format = "{0:#0.00}";
         
    }

    Pawel
  11. Svetoslav
    Admin
    Svetoslav avatar
    649 posts

    Posted 30 Jul 2010 Link to this post

    Hi Pawel,

    With the 2010 Q1 version of Telerik Reporting we added the ability to bind all properties of the report items to expressions. For more information please check the Bindings help topic.

    Back to your question, the next binding expression applies different format strings according to the value of the field Price to the textBox1 item:

    textBox1.Bindings.Add(new Binding("Format"),
        "=IIF(Fields.Price > 100.0, '{0:#0.00}', '{0:$#,##0;($#,##0);}')");

    For more information on the IIF function please check the Expressions help topics.

    For more information on the item binding expressions please see:

    Kind regards,
    Svetoslav
    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
  12. Marco Piumi
    Marco Piumi avatar
    29 posts
    Member since:
    Apr 2005

    Posted 30 Jul 2010 Link to this post

    Before new version, the code worked perfectly !!!!

    The proposed solution does not resolve the problem !!!
    With this solution I do not succeed to having the table datasource (only in processing I have the table datasource ....) !!!

    The second case it does not resolved , I see !!!
    I would have to apply the formatting rule to every field in a row !!!
    The formatting rules would have to be for a single field and for a single table row !!!!
    Thus I would resolve this problem (with formatting rules for a entire row !) !!

    I think TableItem would have to be mainly controllable by code !!!

    For easy Reports, the design mode is sufficient, but for more complicated Reports, the programmer must control mainly with code and events !!!

    I had realized this report with ActiveReports 6, and I am converting to Telerik (I was a telerik custom since 4 years with Web controls ....) , but some strategies of this component I do not understand them !!!

    The programmer must have more control !!!

    Thanks
  13. Svetoslav
    Admin
    Svetoslav avatar
    649 posts

    Posted 05 Aug 2010 Link to this post

    Hello Marco Piumi,

    The reason you cannot set a conditional formatting rule for a row is because the Table item actually does not have rows and columns. Instead a different approach was chosen that makes the Table item extremely powerful and depending on its configuration it can work as a simple repeater (List), horizontal or vertical table and even a complex cross table. For more information please check the Table/Crosstab/List help topics. 

    So generally speaking using the Report API and a proper data model is enough to implement most report scenarios. As reports always display data it is very important to prepare your data in the most suitable way according to your needs. So instead of making calculations on the report level I would suggest to move this to the data model as a dedicated field and use this field's value in the report. This way you will have much simpler reports which only goal is to display data.

    Back to your problems. Regarding the user function we proposed as an event substitution -- user functions are evaluated during the report processing phase just like the ItemDataBinding/ItemDataBound events. In order to access the report item in which scope the current expression is evaluated you can use the ReportItem global object.  So in order to access the txtSubCommessaME TextBox we can modify the user function like this:

    public static string GettxtSubCommessaMEValue(Telerik.Reporting.Processing.TextBox sender, string value, int rowIndex)
    {
        if (rowIndex > 2)
        {
            ..
            return string.Empty;
        }
          
        return value;
    }

    and its usage:

    txtSubCommessaME.Value = "=GettxtSubCommessaMEValue(ReportItem, Fields.SubCommessaME, RowNumber())";

    The idea here is to use the built-in RowNumber() function.

    As far as the conditional formatting is concerned (case #2) -- if you find using the Report designer cumbersome you may create and apply the conditional formatting programmatically in the report's constructor after the InitializeComponent() method call:

    Telerik.Reporting.ReportItemBase[] arr = new Telerik.Reporting.ReportItemBase[] { txtA, txtB, txtC };
    Telerik.Reporting.Drawing.FormattingRule formattingRule = new Telerik.Reporting.Drawing.FormattingRule();
     
    // ... initialize formattingRule's filters and style
     
    foreach (Telerik.Reporting.ReportItemBase item in arr)
        item.ConditionalFormatting.Add(formattingRule);

    As for the missing table cells we are in a process of examining different approaches to enable the missing functionality and in case we find a suitable solution it will be applied as soon as possible.

    Kind regards,
    Author nickname
    the Telerik team
    Svetoslav
    the Telerik team
Back to Top
DevCraft banner