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

Group by custom function

4 Answers 135 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Fredrik
Top achievements
Rank 1
Fredrik asked on 17 Mar 2011, 09:37 PM
Hi, im trying out telerik reporting and im stuck on a (simple?) problem.

Im using the crosstab and im trying to add a row group with an expression with a custom function, like this.

= MyComparer(Fields.A). That works. My problem is when i want to apply my comparer to "Fields" of that expression. Now = MyComparer(Fields) dosent work, but you understand what im trying to do. But what should i apply my function to?
the global object ReportItem gets me the object that my Detail is bound to, not the one my crosstab is iterating over currently.

4 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 22 Mar 2011, 05:50 PM
Hi Fredrik,

Unfortunately we do not understand what you're trying to do and that is why we would appreciate if you elaborate on your exact requirement. If a sample project would help us understand your goal, please open a support ticket and attach it there.

Kind regards,
Steve
the Telerik team
0
Fredrik
Top achievements
Rank 1
answered on 23 Mar 2011, 05:00 PM
I have a Report with a crosstab in the details.

The dataSource for the report is a List<Parent>. The dataSource for the crosstab is the Cild list.

public class Parent {
    public object A;
    public List<Child> Children;
}
 
public class Child {
    public int B;
    public int C;
}

The crosstab has a rowGroup. I go in to the Group Explorer and set the Groupings property to the following expression: [= Fields.B].
Works like a charm. Now instead of grouping on B, i have an IEqualityComparer for the child class i want to use. In the code behind i have this code.
public static int GetHash(Child child)
{
    return new ChildDataComparer().GetHashCode(child);
}

Question: How should the expression look to use this function? or rather, how should the argument look? I've tried using:

= GetHash(ReportItem.DataObject.RawData)

But ReportItem.DataObject.RawData seems to be the Parent in this case. How do i apply the function to the child itself instead of its properties?


0
Fredrik
Top achievements
Rank 1
answered on 24 Mar 2011, 05:31 PM
Ok, i found it out. It was as simple as i thought it was. Instead of using ReportItem.DataObject.RawData i just wrote RawData and it worked.
0
jameer
Top achievements
Rank 1
answered on 06 Apr 2011, 08:42 AM
Hi,

I have crosstab control and I have used table into it for my details information. But I am not able to display the data which is come from crosstab iteration into the table. So please help me on the same ASAP. I have tried "=ReportItem.DataObject" as datasource for table control but it is always showing the first record of main data source. not getting from crosstab iteration.


I have dead lines so please let me know if any one have solution.

thanks,
Jameer Patel
Tags
General Discussions
Asked by
Fredrik
Top achievements
Rank 1
Answers by
Steve
Telerik team
Fredrik
Top achievements
Rank 1
jameer
Top achievements
Rank 1
Share this question
or