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

Table item rows numbering

3 Answers 1054 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Yavor
Top achievements
Rank 1
Yavor asked on 24 Feb 2011, 02:44 PM
I have the following situation - Table item with grouping. Since I don't need the detail row, but only group total rows I deleted the details row (I found no way to hide the entire row), so my table only cosists of group total rows. I want these rows to have numbering. I added a new column with the RowNumber() expression but when I execute the report it returns 1 for all the rows. Please advice me urgently how to fix this problem.

3 Answers, 1 is accepted

Sort by
0
Patrick
Top achievements
Rank 1
answered on 01 Mar 2011, 11:49 AM
Sorry, I can't help you. I just want to say, that I have the same problem!
I'm using Telerik Reporting Q3 2010 with VS 2010 and .Net Framework 4.0.

I have a report. On this report I'm adding a table. I have configured a list of my business objects as datasource.
This datasource is the datasouce of my table.
When I render this report/table all my entries are added to the table! So, it works very well!

Now I wanna have the rownumber in the first column, so I added this expression on my first column: "= RowNumber()", my second column is like "Fields.Name", third like "Fields.ID" and so on (just the properties of my business object).

My result looks like this:

RowNumber  Name            ID (Header-Row)
1                   FooName1    1
1                   FooName2    2
1                   FooName3    4

So, the table will be generated, but the rownumber always says "1"!!
Is there any help or trick? Anyone?

Thank you for your advices!
0
Peter
Telerik team
answered on 01 Mar 2011, 06:31 PM
Hello,

Yavor:

You can simulate GroupNumber() function with the RunningValue function and CountDistinct User/Custom Aggregate Function: 
= RunningValue("crosstab1",CountDistinct(Fields.Manufacturer))

User Aggregate Functions allow you to apply custom logic when accumulating values over a set of data records. They are used by the Telerik Reporting engine as all built-in aggregate functions. Check out the following code snippets that illustrates how to implement a CountDistinct aggregate:

[AggregateFunction(Name = "CountDistinct", Description = "Defines an aggregate function to count distinct values.")]
public class CountDistinctAggregate : Telerik.Reporting.Expressions.IAggregateFunction
{
    private System.Collections.Generic.List<object> distinctValues;
    /// <summary>
    /// Initializes the current aggregate function to its initial state
    /// ready to accumulate and merge values.
    /// </summary>
    /// <remarks>
    /// This method is called every time the accumulation of values must
    /// start over for a new subset of records from the data source.
    /// </remarks>
    public void Init()
    {
        this.distinctValues = new System.Collections.Generic.List<object>();
    }
  
    /// <summary>
    /// Accumulates new argument values to the current aggregate function.
    /// </summary>
    /// <remarks>
    /// This aggregate function accepts one argument:
    /// number - a numeric value to accumulate to the aggregate function;
    /// </remarks>
  
    public void Accumulate(object[] values)
    {
        if (!distinctValues.Contains(values[0]))
        {
            distinctValues.Add(values[0]);
        }
    }
    /// <summary>
    /// Merges the specified aggregate function to the current one.
    /// </summary>
    /// <paramname="Aggregate">
    /// Specifies an aggregate function to be merged to the current one.
    /// </param>
    /// <remarks>
    /// This method allows the reporting engine to merge two accumulated
    /// subsets of the same aggregate function into a single result.
    /// </remarks>
    public void Merge(IAggregateFunction aggregate)
    {
        // Accumulate the values of the specified aggregate function.
        System.Collections.Generic.List<object> sums1 = ((CountDistinctAggregate)aggregate).distinctValues;
        foreach (object o in sums1)
        {
            this.Accumulate(new object[] { o });
        }
    }
  
    /// <summary>
    /// Returns the currently accumulated value of the aggregate function.
    /// </summary>
    /// <returns>
    /// The currently accumulated numeric value of the aggregate function.
    /// </returns>
    public object GetValue()
    {
        return this.distinctValues.Count;
    }
}

Note that you may not be able to preview the report in Designer Preview.

Additionally for better understanding of the Custom Aggregates and if you want create custom ones check the Dynamic Sorting of Reporting Crosstabs Using a Custom Aggregate Function blog article.

Patrick:
We are not sure what is causing the described behavior of the RowNumber(). Generally you have to add it to a Table Detail Group in order to count the rows. If you still experience any troubles we will appreciate if you open a support thread and send us a sample runnable project that exhibits the issue to debug locally.

Best wishes,
Peter
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Pravin
Top achievements
Rank 1
answered on 21 Oct 2011, 07:29 AM
I have the same problem. I am using the trial version of telerik reporting Q2 2011.
Tags
General Discussions
Asked by
Yavor
Top achievements
Rank 1
Answers by
Patrick
Top achievements
Rank 1
Peter
Telerik team
Pravin
Top achievements
Rank 1
Share this question
or