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

sorting detail section programmatically

4 Answers 247 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lawrence
Top achievements
Rank 1
Lawrence asked on 25 Oct 2010, 04:03 PM
With the new Q2 release Telerik Reports hyperlinks are now supported,
and I am trying to enable interactive sorting without tables. Table
performance seems very slow or even hangs  when using table grouping.

With the fields in the detail section directly, and  using the NeedDataSource, or ItemDataBinding(for the report details section)  event I can grab my report params but in these events the sorting methods don't work. "Telerik.Reporting.Data.SortDirection.Asc"

The sorting does work under InitializeComponet() but
I can't get the params or at least don't know how at that stage of
report rendering. .

I am designing the reports in a class library  

Thanks

Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;
 
           if ((string)report.Parameters["SortDir"].Value == "Asc")
           {
 
               this.Sorting.Add(new Sorting("firstname", Telerik.Reporting.Data.SortDirection.Asc));
               
                
           }

private void Report3_NeedDataSource(object sender, EventArgs e)
        {

            Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;

            if ((string)report.Parameters["SortDir"].Value == "Asc")
            {

                this.Sorting.Add(new Sorting("firstname", Telerik.Reporting.Data.SortDirection.Asc));
                report.DataSource = this.sqlDataSource1;
                
            }
            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }




private void Report3_NeedDataSource(object sender, EventArgs e)
        {

            Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;

            if ((string)report.Parameters["SortDir"].Value == "Asc")
            {

                this.Sorting.Add(new Sorting("firstname", Telerik.Reporting.Data.SortDirection.Asc));
                report.DataSource = this.sqlDataSource1;
                
            }
            //
            // TODO: Add any constructor code after InitializeComponent call
            //
       
private void Report3_NeedDataSource(object sender, EventArgs e)
        {

             report.DataSource = this.sqlDataSource1;
                
            }
            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }
private void Report3_NeedDataSource(object sender, EventArgs e)
        {

            Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;

            if ((string)report.Parameters["SortDir"].Value == "Asc")
            {

                this.Sorting.Add(new Sorting("firstname", Telerik.Reporting.Data.SortDirection.Asc));
                report.DataSource = this.sqlDataSource1;
                
            }
            //
            // TODO: Add any constructor code after InitializeComponent call
            //
       {

            Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;

            if ((string)report.Parameters["SortDir"].Value == "Asc")
            {

                this.Sorting.Add(new Sorting("firstname", Telerik.Reporting.Data.SortDirection.Asc));
                report.DataSource = this.sqlDataSource1;
                
            }
            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }
private void Report3_NeedDataSource(object sender, EventArgs e)
        {

            Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;

            if ((string)report.Parameters["SortDir"].Value == "Asc")
            {

                this.Sorting.Add(new Sorting("firstname", Telerik.Reporting.Data.SortDirection.Asc));
                report.DataSource = this.sqlDataSource1;
                
            }
            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

4 Answers, 1 is accepted

Sort by
0
Scott McNeany
Top achievements
Rank 1
answered on 26 Oct 2010, 03:50 PM
I am also looking for a way to pass Sort Direction as a parameter. Can it be done in the table's ItemDataBinding event handler?
0
Lawrence
Top achievements
Rank 1
answered on 26 Oct 2010, 04:20 PM
Yes it can there are examples in other posts on that.

I am not using tables and trying to get it to work,
by just dropping fields in the detail section. 

Larry
0
Lawrence
Top achievements
Rank 1
answered on 27 Oct 2010, 10:44 PM
Seemed to have figured this out. Using the main report's ItemDataBindingEvent
grab the parameters and set the sorting as needed. Set the sorting of the main report
using a function = Fields(Parameters.SortBy.Value) 
private void TheReport_ItemDataBinding(object sender, EventArgs e)
       {
          
 
           if (((string)this.ReportParameters["SortDir"].Value) == "Asc")
           {
 
                this.Sorting[0].Direction = Telerik.Reporting.Data.SortDirection.Asc;
           }
           else
           {
               this.Sorting[0].Direction = Telerik.Reporting.Data.SortDirection.Desc;
           }
 
       }
0
Steve
Telerik team
answered on 28 Oct 2010, 07:39 AM
Hi guys,

@Scott: check the following forums:
@Larry: You can't access report parameters in the report constructor because they are not set until after the instance is created. This is not something specific to Telerik Reporting, but applicable for any .NET class. Check out the above threads if you haven't yet and see how the sorting is implemented for the Table item. The same approach is applicable for any report data item including the report.

In fact we're working on something similar for the upcoming Q3 release that would be out of the box feature, so stay tuned :)

Greetings,
Steve
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
Tags
General Discussions
Asked by
Lawrence
Top achievements
Rank 1
Answers by
Scott McNeany
Top achievements
Rank 1
Lawrence
Top achievements
Rank 1
Lawrence
Top achievements
Rank 1
Steve
Telerik team
Share this question
or