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

How to pass parameter at runtime to filter report accordingly?

7 Answers 391 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Saad
Top achievements
Rank 1
Saad asked on 06 Jan 2010, 08:23 AM
Helo,
I just want to ask what if i want to filter my results in my database query at runtime? That is, if i have a option on one page to select 'From DateTime' and 'To Datetime' and click generate report, then how would i pass that arguments to 'Something_NeedDataSource' event so that parameters can be given to my query at runtime? Is there any other wayt to accomplish it so please let me know.
Thank you

7 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 06 Jan 2010, 03:12 PM
Hello saadi,

Take a look at the following video: Telerik Reporting - Design Time Support for Parameterized Queries for more info.

Best wishes,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Saad
Top achievements
Rank 1
answered on 06 Jan 2010, 05:37 PM
I did watch this movie, but if i`ll make a class library for my report then how would I make use of DatasetTableAdapter query (storeprocedure in my scenario to return xml) for my database, as it will be a separate separate project?
Please note that I need to retrieve xml data from my database!
0
Saad
Top achievements
Rank 1
answered on 07 Jan 2010, 07:51 AM
I have noticed that whatever changes if make in any report sample given on telerik blog for reporting....It stops working.
What is wrong with it? I did download the following sample too
http://blogs.telerik.com/kevinbabcock/posts/09-02-06/bind_your_telerik_reports_to_xml_data.aspx
And again did nothing but added some code and again deleted it, then report stopped working!!!!!!
I am trying for 5 days for make a single report and cant even see any wrong results though!
0
Vassil Petev
Telerik team
answered on 08 Jan 2010, 09:59 AM
Hello saadi,

We are afraid that we are not sure how to help you. Did the report work? What code did you add and delete? If the report stopped working, why don't you start from scratch?

Did the blog help you achieve what you need? If yes, do you have more specific questions related to your project?


Regards,
Vassil
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Saumyadip
Top achievements
Rank 2
answered on 07 Aug 2015, 02:01 PM
How to get search button to grab new data from database in Telerik Report using code .


HTML Section 
@using Telerik.Reporting.Examples.CSharp.ZipCodeReport;


@{
    ViewBag.Title = "Zip Code Report";
    Layout = "~/Views/Shared/_LayoutAllReport.cshtml";
}
@section styles
{
    <link href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet" />
    <link href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.common.min.css" rel="stylesheet" />
    @*<link href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.blueopal.min.css" rel="stylesheet" />*@


    <style>
        #reportViewer1 {
            position: relative;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            overflow: hidden;
            font-family: Verdana, Arial;
            height: 1150px;
        }
         #reportViewer1 .trv-parameters-area {
            display:none;
        }


    </style>
    <link href="@Url.Content("~/ReportViewer/styles/telerikReportViewer-9.0.15.324.css")" rel="stylesheet" />
}


<div style="background:#fff; border-bottom: 3px solid #396087;">
    <div class="container">
        <div class="row">
            <div class="col-md-9">
                <div class="clearfix">
                    <div class="col-md-2 form-group clearfix">
                        <label>Date From</label>
                        @(Html.Kendo().DatePicker().Name("DateFrom")
                              .Value(Utility.Common.common.ConvertUTCtoLocalTime(DateTime.UtcNow)).Format("MM/dd/yyyy")
                              .Max(DateTime.Today)
                              .Events(e =>
                              {
                                  e.Change("dateChanged");
                              })
                        )
                    </div>
                    <div class="col-md-2 form-group clearfix">
                        <label>Date To</label>
                        @(Html.Kendo().DatePicker().Name("DateTo")
                          .Value(Utility.Common.common.ConvertUTCtoLocalTime(DateTime.UtcNow)).Format("MM/dd/yyyy")
                          .Max(DateTime.Today)
                          .Events(e =>
                          {
                              e.Change("dateChanged");
                          })
                        )
                    </div>
                    <div class="col-md-2 form-group clearfix">
                        <label>&nbsp;</label>
                        @(Html.Kendo().Button()
                                .Name("btnSearch")
                                .HtmlAttributes(new { type = "button", @class = "small-button" })
                                .Content("Search"))


                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="top-btn floatR" style="margin-top:20px;">
                    <a id="iconTextButton2" href="/Patient/List" class="k-button" data-role="button" role="button" aria-disabled="false" tabindex="0">Find Patient</a>
                    <script>
                        jQuery(function () { jQuery("#iconTextButton2").kendoButton({}); });
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="container">
    <div class="row">
        @{
            var typeReportSource = new TypeReportSource() { TypeName = typeof(ZipCodeReport).AssemblyQualifiedName };
            typeReportSource.Parameters.Add("DisplayDateFrom", Utility.Common.common.ConvertUTCtoLocalTime(DateTime.UtcNow).ToString("MM/dd/yyyy"));
            typeReportSource.Parameters.Add("DisplayDateTo", Utility.Common.common.ConvertUTCtoLocalTime(DateTime.UtcNow).ToString("MM/dd/yyyy"));
        }


        @(Html.TelerikReporting().ReportViewer()
                                        // Each report viewer must have an id - it will be used by the initialization script
                                        // to find the element and initialize the report viewer.
                            .Id("reportViewer1")
                                        // The URL of the service which will serve reports.
                                        // The URL corresponds to the name of the controller class (ReportsController).
                                        // For more information on how to configure the service please check http://www.telerik.com/help/reporting/telerik-reporting-rest-conception.html.
                            .ServiceUrl(Url.Content("~/api/reports/"))
                                        // The URL for the report viewer template. The template can be edited -
                                        // new functionalities can be added and unneeded ones can be removed.
                                        // For more information please check http://www.telerik.com/help/reporting/html5-report-viewer-templates.html.
                            .TemplateUrl(Url.Content("~/ReportViewer/templates/telerikReportViewerTemplate-9.0.15.324.html"))
                                        // Strongly typed ReportSource - TypeReportSource or UriReportSource.
                                                            .ReportSource(typeReportSource)
                                        // Specifies whether the viewer is in interactive or print preview mode.
                                        // PRINT_PREVIEW - Displays the paginated report as if it is printed on paper. Interactivity is not enabled.
                                        // INTERACTIVE - Displays the report in its original width and height with no paging. Additionally interactivity is enabled.
                            .ViewMode(ViewModes.PRINT_PREVIEW)
                                        // Sets the scale mode of the viewer.
                                        // Three modes exist currently:
                                        // FIT_PAGE - The whole report will fit on the page (will zoom in or out), regardless of its width and height.
                                        // FIT_PAGE_WIDTH - The report will be zoomed in or out so that the width of the screen and the width of the report match.
                                        // SPECIFIC - Uses the scale to zoom in and out the report.
                            .ScaleMode(ScaleModes.SPECIFIC)
                                        // Zoom in and out the report using the scale
                                        // 1.0 is equal to 100%, i.e. the original size of the report
                            .Scale(1.0)
                                        // Sets whether the viewer’s client session to be persisted between the page’s refreshes(ex. postback).
                                        // The session is stored in the browser’s sessionStorage and is available for the duration of the page session.
                            .PersistSession(false)
                                        // Sets the print mode of the viewer.
                            .PrintMode(PrintMode.AutoSelect)
                                        // Defers the script initialization statement. Check the scripts section below -
                                        // each deferred script will be rendered at the place of TelerikReporting().DeferredScripts().
                            .Deferred()




        )


    </div>
</div>






Script Section




@section scripts
{
    <!--kendo.all.min.js can be used as well instead of kendo.web.min.js and kendo.mobile.min.js-->
    <script src="@Url.Content("~/ReportViewer/js/telerikReportViewer-9.0.15.324.js")"></script>
    <script src="http://cdn.kendostatic.com/2013.2.918/js/kendo.web.min.js"></script>
    <!--kendo.mobile.min.js - optional, if gestures/touch support is required-->
    <script src="http://cdn.kendostatic.com/2013.2.918/js/kendo.mobile.min.js"></script>
    @(




        // All deferred initialization statements will be rendered here
        Html.TelerikReporting().DeferredScripts()
    )


    <script type="text/javascript">


        function ReportViwerLoad()
        {
            var reportUrl = '@Url.Action("GetConvertUTCtoLocalTime", "Report")';
            reportUrl = reportUrl + '?DateFrom=' + $("#DateFrom").val() + ' ' + get12HourFormatTime(new Date()) + '&DateTo=' + $("#DateTo").val() + ' ' + get12HourFormatTime(new Date());
            $.ajax({
                type: "POST",
                url: reportUrl,
                dataType: 'json',
                success: function (data) {
                    var viewer = $("#reportViewer1").data("telerik_ReportViewer");
                    viewer.reportSource({
                        report: viewer.reportSource().report,
                        parameters: { DateFrom: data.returnVal.DateFrom, DateTo: data.returnVal.DateTo, DisplayDateFrom: $("#DateFrom").val(), DisplayDateTo: $("#DateTo").val() }
                    });





                    viewer.refreshReport();
                },
                error: function () {  }
            });
        }




        $("#btnSearch").click(function () {
            ReportViwerLoad();
        });


        function dateChanged()
        {
            ReportViwerLoad();
        }


    </script>
}
0
Stef
Telerik team
answered on 12 Aug 2015, 07:47 AM
Hello Saumyadip,

You can upgrade to Telerik Reporting Q2 2015 SP1 v9.1.15.731 and use the new ReportSharingTimeout setting of the Reporting REST service configuration - HTML5 Report Viewer and Reporting REST services cache management.

In older versions, you can test the approaches described in the  Web Api Caching and resolving issues forum thread.


I hope this information is helpful.

Regards,
Stef
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Saumyadip
Top achievements
Rank 2
answered on 12 Aug 2015, 07:56 AM

Hello Stef,

              I appreciate your post , but i post the solution for that issue . I am not facing any problem regarding that issue. you can close the ticket regarding this problem . And also i am trying to pass parameter  run time in Telerik report.

Thanks

Saumyadip

 

 

Tags
General Discussions
Asked by
Saad
Top achievements
Rank 1
Answers by
Steve
Telerik team
Saad
Top achievements
Rank 1
Vassil Petev
Telerik team
Saumyadip
Top achievements
Rank 2
Stef
Telerik team
Share this question
or