Sorting Direction via Report Parameter

0 Answers 129 Views
Report Parameters Report Viewer - HTML5
Balaji
Top achievements
Rank 1
Veteran
Balaji asked on 04 Dec 2021, 02:57 PM

Is it possible to control the sorting direction of the table via report parameter?

I want to pass Asc or Desc value as Report Parameter and sort the table rows.

Please advice.

Thanks

BV

Neli
Telerik team
commented on 08 Dec 2021, 04:07 PM

Hi Balaji,

I am afraid that we don't provide such a functionality out-of-the-box. However, because I see that you use the HtmlReportViewer, you may test implementing CustomReportSourceResolver a which will allow you to set the Sorting programmatically. In it, you need to make an instance of the report, access the table and add the Sorting:

public class CustomReportSourceResolver : IReportSourceResolver
{
    public ReportSource Resolve(string report, OperationOrigin operationOrigin, IDictionary<string, object> currentParameterValues)
    {
        var reportPackager = new ReportPackager();
        InstanceReportSource irs = new InstanceReportSource();
        using (var sourceStream = System.IO.File.OpenRead("Reports/Report1.trdp"))
        {
            var reportInstance = (Report)reportPackager.UnpackageDocument(sourceStream);
    var table1 = (Table)reportInstance.Items.Find("table1", true).FirstOrDefault();
    table1..Sortings.Clear();
    table1..Sortings.Add(new Telerik.Reporting.Sorting("= Fields.Group", Telerik.Reporting.SortDirection.Asc));
    irs.ReportDocument = reportInstance;
        }
        return irs;
    }

}

No answers yet. Maybe you can help?

Tags
Report Parameters Report Viewer - HTML5
Asked by
Balaji
Top achievements
Rank 1
Veteran
Share this question
or