Formating is HARD...

5 posts, 0 answers
  1. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 07 Nov 2011 Link to this post

    .. or I'm even dumber than generally accepted.

    Have a look at the attached image.

    This is from the detail section of a report. The detail section contains a crosstab (highlighted in Red.

    Now, The crosstab has 2 row groups (and the content of these in show in bold).

    I've been trying to find a way of getting the whole row for each top-level row group to be formated with the same background colour.

    I thought Id cracked it by doing this in code ...
    static int TabCount = 0;
    public static int GetTabCount()
    {
        return TabCount;
    }
    private void textBox25_ItemDataBound(object sender, EventArgs e)
    {
        TabCount++;
    }

    textBox25 is the textbox holding the top-level grouping value.

    I then, for both row groups and the detail section, set up a Conditional Formating rule with Filter="=GetTabCount() % 2" Condition = "Equal" an Value = "=1".

    As you can see from the screen shot, this works for the row group cells but not for the detail cell.

    I did a test and got the system to echo the value of GetTabCount() for each of the cells in the crosstab and got:
    0 - 0 - 3
    1 - 1 - 3
    2 - 2 - 3

    And I'll be damned if I can figure out why.

    It seems that textBox25 is being bound more often that I think it should (so I guess my understanding og that is wrong too) and that the detail cells are being bound after the all of the row grouop cells on all of the rows.

    Simply formating a report shouldn't be this hard.

    If anyone can off any help, I will very grateful.

    --
    Stuart

  2. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 07 Nov 2011 Link to this post

    I got around the issue by:
    1. Adding a count item to my datasource for the CrossTab and populating this when I populate the DataSource proper;
    2. Replacing the GetTabCount() method with the code below;
    3. Replacing the Conditional Formating exporession to pass in the ReportItem object.
    public static int GetTabCount(Telerik.Reporting.Processing.ReportItem Caller)
    {
        return (Caller.DataObject.RawData as TemplateData).TabCount;
    }

    It still seems a hell of a lot of work to go through just to colour the background of a row of data, but ...

    I'd still be interested in any hint/tips anyone has about better ways of doing this.

    --
    Stuart

  3. DevCraft banner
  4. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 10 Nov 2011 Link to this post

    Hello Stuart,

    Maybe a little explanation on the Table group is necessary, so here it is, depending on the grouping criteria, we have:
    • dynamic groups - have any Grouping expression, ex. group1.Grouping.Add(new Grouping("=Fields.Country")). For the dynamic groups, the corresponding row/column will repeat for every record of the grouped data.
    • static groups - no grouping criteria at all. For the static groups the corresponding row/column is rendered only once.
    • detail groups -have a single empty grouping, ex. group1.Grouping.Add(new Grouping()). Usually you have only one row -or- column detail group. For a detail group the corresponding row/column is repeated for every row of the Table's data source. You may think of the detail TableGroup as the Report's Detail section.
    Generally the easiest way to "echo" the row number is to use the built-in RowNumber() function. If necessary you can use the data scope related function Exec(scope, expression). See the latter help article for more info.

    Kind regards,
    Steve
    the Telerik team

    Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

  5. Some
    Some avatar
    19 posts
    Member since:
    Mar 2009

    Posted 14 Dec 2011 Link to this post

    Stuart,
    I appreciate you sharing the knowledge with the community.  Might be a dumb question but in your code snippet below:

    public static int GetTabCount(Telerik.Reporting.Processing.ReportItem Caller) 
        return (Caller.DataObject.RawData as TemplateData).TabCount; 
    }

    what is the type TemplateData or more specifically what namepace is it in?  I don't find it mentioned anywhere.

    Also Steve in your post are you saying there is an easier way of achieving Stuarts goal or are you explaining why he received the results that he did with the original GetTabCount() approach.
  6. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 19 Dec 2011 Link to this post

    HI,

    no, you won't find any mention of TemplateData as it is a class I wrote just to hold, well, data from the template in.

    The point is, the DataObject of the ReportItem will be the same type as any item in the DtaaSource.

    -- 
    Stuart
Back to Top
DevCraft banner