Pass parameters to JS Viewer

Posted by: goran.borevkovic on 30 May 2019, 12:17 am EST

    • Post Options:
    • Link

    Posted 30 May 2019, 12:17 am EST

    Hi,

    I have parameter in the report (parameter name is period), I want to set its value from the js code. I have tried the code below but it doesn’t work:

    currentViewer = GrapeCity.ActiveReports.JSViewer.create({

    element: ‘#root’,

    reportService: {},

    reportID: reportId,

    settings: {

    zoomType: ‘FitPage’

    },

    reportParameters: [

    {

    name: ‘period’,

    value: ‘1.1.2016-31.12.2019’

    }]

    });

    Best,

    Goran

  • Posted 30 May 2019, 1:06 am EST

    Hello```

    
    Could you please use the following code:
    
    
    
    Hope it helps.
    
    Thanks.
  • Posted 31 May 2019, 1:31 am EST

    Hi,

    Unfortunately it doesn’t help. I have tried this, but it doesn’t work. If parameter has the Prompt user set to true it works fine, but if I try to pass value in create function nothing happened. Create method in jsViewer.min.js finish without error, but parameter in the report (rpt and rdlx) are unchanged. It looks like common functionality it is weird that is not working. I have the latest version the ActiveReport 13 SP1.

    By the way, is there are possibility to open database table in the report script section?

    Thanks,

    Goran

  • Posted 3 June 2019, 4:45 am EST

    Hello,

    Could you please confirm that do yo need hotfix for this issue?

    Thanks.

  • Posted 3 June 2019, 10:11 pm EST

    Yes, I need hotfix for this problem.

    Thanks,

    Goran

  • Posted 3 June 2019, 11:06 pm EST

    Hello,

    Thanks for the information.

    Could you please explain what do you mean by the following line:

    By the way, is there are possibility to open database table in the report script section?

    Thanks.

  • Posted 4 June 2019, 12:24 am EST

    Hello,

    I am able to reproduce the issue with .rpx format report. Hence, I have escalated the issue to our development team(273006) and will inform you once I have any information from them.

    Also, I am not able to reproduce the issue with “.rdlx” format report. “PromptUser” property is not part of the “.rdlx” report.

    By the way, is there are possibility to open database table in the report script section?

    Could you please explain in detail so that I will assist you accordingly.

    Thanks.

  • Posted 4 June 2019, 10:07 pm EST

    Hi,

    My question is can I get DataSet from the database using the OleDBDataSource object (or something else)

    For example;

    GrapeCity.ActiveReports.Data.OleDBDataSource newDs = new GrapeCity.ActiveReports.Data.OleDBDataSource();

    	newDs.ConnectionString = ds.ConnectionString;
    	newDs.SQL = "SELET * FROM Customers"
    

    Is there are possibility to get data from the newDs object?

    Best,

    Goran

  • Posted 5 June 2019, 7:42 pm EST

    Hello,

    You can refer the following forum case to achieve your requirement:

    https://www.grapecity.com/forums/ar-dev/ar-13-jsreport-viewer-pass#helloyou-need-to-use-the-u

    Hope it helps.

    Thanks.

  • Posted 11 June 2019, 12:06 am EST

    Hello,

    I am glad to you that your issue is fixed in the latest hotfix now. Please use the following link to download the installer:

    http://cdn.grapecity.com/ActiveReports/AR13/hotfixes/ActiveReports-v13.1.17447.0.msi

    Thanks,

  • Posted 13 June 2019, 3:08 am EST

    Hi,

    Thank you for hot fix, parameters work now. But I have another problem. Actually, this problem occurs with the last SP1. Reports work in the design time. But when I deploy application to named web site the report not found error occurs.

    I replaced jsViewer.min.js and jsViewer.min.css files in my project.

    Best,

    Goran

  • Posted 13 June 2019, 7:55 pm EST

    Goran,

    Could you please make sure that the path of the report is correct when you deployed the application to IIS.

    Thanks.

  • Posted 14 June 2019, 12:07 am EST

    Yes, the path is correct for sure. Before the last SP1 everything was OK. The application works in the production and it is deployed on three servers. After upgrade I’ve changed all js files with the new one (if I don’t “Cannot read property ‘trim’ of undefined” occurs), but doesn’t help. It seems easy to reproduce this error. For test use sample dot net core project with JSViewer. First check that it works in the design time. Second, from Visual studio 2017 publish project to the package (standard VS publish procedure). Be sure you have instal deploy for IIS. Deploy package to the named site. Run the sample.

    The same procedure before SP1 works fine. Now it works only in the design time. When I uninstall the SP1 it works fine again.

    I just wonder why other people don’t have this problem. It looks like big issue.

    Thank you,

    Goran

  • Posted 16 June 2019, 6:23 pm EST

    Hello Goran,

    We are sorry for the inconvenience caused to you.

    I have done the followings steps but unable to reproduce the issue at my end:

    1: Install the latest hotfix

    2: Publish the “JSViewer_MVC(Core)” sample located at(C:\Users{User Name}\Documents\GrapeCity Samples\ActiveReports 13\Web\JSViewer_MVC(Core))

    3: Copy the “Reports” folder (from C:\Users{USer Name}\Documents\GrapeCity Samples\ActiveReports 13\Web) to publish folder

    4: Open IIS and add Application Pool: set Name, .NET CLR version to No Managed Code, Managed pipeline mode to Integrated. Also open Advanced settings: Set Identity to Custom account.

    5: Open IIS and Add Website: set Site name, Physical path to Publish folder from 2nd step, choose created Application pool, correct free port and Connect as Specific user (dw[user]).

    6: Browse the site and found that all reports are displayed

    Could you please try with the above steps and check if the issue also reproducible with above steps at your end.

    If the issue is only reproducible with your application, then request to please share the stripped down the application so that I can reproduce the issue at my end.

    Also, please make sure that you have updated the assmebly version in “Web.config” file.

    Thanks.

  • Posted 17 June 2019, 12:31 am EST - Updated 30 September 2022, 6:41 am EST

    Hi,

    I did not explain my problem well enough. Problem occurs when you deploy web package on the existing web site. We deploy all application on the default web site on port 80. I have created web package of the JSViewer Core sample (you have to copy reports folder manually). You can get it here: https://1drv.ms/u/s!Amt_7ucA2Y4Dgfhekxs9JI8JOVbpAA

    In addition, this picture that shows how we deploy this package on the IIS server. After deploy the site will be at \inetpub\wwwroot\ARTest.

    Thanks for your help

  • Posted 17 June 2019, 12:31 am EST

  • Posted 17 June 2019, 11:47 pm EST

    Hello,

    Before publishing to IIS, please set PublishToIIS property to ‘true’ in the ProjectName.csproj file:

    false

    The IISVirtualDirectoryName property contains the name of the IIS Virtual Directory:

    /ProjectName/

    (ARTest in your case)

    Could you please provide the new package link if the issue is not resolved by the above suggestion.

    Thanks.

  • Posted 26 June 2019, 10:25 pm EST

    Hi,

    It doesn’t help. You have changed something between the first version and the SP1. That change cause the problem. If I use the first version everything is fine with the default setting. Should be very easy to reproduce this problem.

    1. Use Visual Studio 2017 to create or open core project JSViewer (JSViewer_MVC(Core))
    2. Publish project to the package. Pictures 1 and 2

      Picture 1:

      https://1drv.ms/u/s!Amt_7ucA2Y4DgflI7Oujer53EnUCjg

    Picture 2:

    https://1drv.ms/u/s!Amt_7ucA2Y4DgflJEkGq5LYv-WzwIw

    3. Deplay package to the IIS

    https://1drv.ms/u/s!Amt_7ucA2Y4DgfhdrMrgFI1ilKRXGA

    4. Finally my project placed in IIS like this:

    https://1drv.ms/u/s!Amt_7ucA2Y4DgflK7-1FV7raIAffPw

    5. When I run the project in the browser this error occur:

    https://1drv.ms/u/s!Amt_7ucA2Y4DgflLpK-onxPhpFeGXQ

    Note important detail. If my application run on the root it will work, but on the named folder it does not. So this will work:

    http://localhost/Report?id=100

    But this does not:

    http://localhost/HamagReport/Report?id=100

    ActiveRebport binaries and js files are same version. If one use different version this error will occurs:

    Different versions error:

    https://1drv.ms/u/s!Amt_7ucA2Y4DgflM9YmYfe8MrB73fw

    Please let me know if you need more information about this problem.

    Unfortunately, right now only way to use ActiveReport is to downgrade to the first version.

    Best,

    Goran

  • Posted 30 June 2019, 10:42 pm EST

    Hello,

    I am able to reproduce the issue at my end. I have escalated the issue(273739) to our development team and will inform you once I get any information from them.

    Sorry for the inconvenience caused to you.

    Thanks.

  • Posted 22 November 2019, 1:59 am EST

    Hi,

    I installed the last version (v13.2.18250.0), but still I have the same problem. I can work around this problem changing the jsViewer.min.js and the baseServerApi.js. I put web name directly in script, for example instead (13. line in baseServerApi.js):

    return ‘/api/’ + path + queryString;

    I use:

    return ‘/MySite/api/’ + path + queryString;

    But it is not a good way to do it. Please let me know if there are some changes about this problem.

    Best,

    Goran

  • Posted 22 November 2019, 2:40 am EST

    Hello,

    What a coincidence! This issue has been addressed in the latest hotfix of AR13 Sp2 which has ready today only. We are very sorry for taking so much time to fix this issue.

    Please download the build from the following link;

    http://cdn.grapecity.com/ActiveReports/AR13/hotfixes/ActiveReports-v13.2.18663.0.msi

    We appreciate for your patience and trust in us :slight_smile:

    Thanks,

    Mohit

  • Posted 22 November 2019, 2:29 pm EST

    HI,

    Probably I miss something, but I still have the same problem. The JSViewer can work with work around (changing URL in the jsViewer.min.js file), but work around for designer (changing URL in the baseServerApi.js file) doesn’t solve all problems. I can see reports in the folder, but cannot see dataset and templates. If I try to run report from the designer I got error TypeError: options.makeViewerUrl is not a function in the viewer-container.js file line 14

    Best,

    Goran

  • Posted 25 November 2019, 1:13 am EST

    Hello Goran,

    Could you please try after changing the RoutePrefix in “TemplatesController.cs” and “DataSetsController.cs” class.

    Thanks,

    Mohit

  • Posted 25 November 2019, 11:39 pm EST

    Hi Mohit,

    I’ve already tried change Route attribute in my project but it does not work. Probably I do something wrong. Could you send the code snippet?

    Best,

    Goran

  • Posted 26 November 2019, 6:00 pm EST

    Hello Goran,

    I have done the following steps:

    1: Change the following code in “WebDesigner_MVC(Core)\Views\Design\Index.cshtml” file

    <!-- No Virtual Directory -->
    	@*//<base href="/">*@
    
    	<!-- For Virtual Directory -->
           <base href="/WebDesigner_MVC(Core)/">
    

    2: Change the following code in “WebDesigner_MVC(Core)\Views\Preview\Index.cshtml” file

    <!-- No Virtual Directory -->
    	@*<base href="/">*@
    
    	<!-- For Virtual Directory -->
        <base href="/WebDesigner_MVC(Core)/">
    

    3: Change the following code in “WebDesigner_MVC(Core)\wwwroot\baseServerApi.js” file

    /* No Virtual Directory */
    		//return '/api/' + path + queryString;
    
    		/* For Virtual Directory */
    		return '/WebDesigner_MVC(Core)/api/' + path + queryString;
    

    4: Publish the application.

    5: Place the resource folder in the Publish folder

    6: Create a virtual directory with WebDesigner_MVC(Core) name.

    7: Web Designer deployed successfully.

    Thanks,

    Mohit

  • Posted 27 November 2019, 11:17 pm EST

    Hi MOhit,

    This doesn’t work. I don’t understand how other users can work because it’s basic functionality. There are some obvious bugs. For example, in the viewer-container.js script line 14:

    var previewUrl = options.makeViewerUrl();

    The makeViewerUrl function doesn’t exist. I can work around it by hard coring path like this:

    var previewUrl = options.baseUrl + options.reportInfo.id;

    or this

    var previewUrl = ‘/MyWeb/preview/’ + options.reportInfo.id;

    I have to change several AR scripts to run report. But even than when I try to run report from designer an error occurs. AR looking for reports on folder. I have two folders, one for built in reports (Resources folder), and other for designer (Designer folder). The AR tries to find report in wrong folder (built in reports folder)

    Error:

    Could not find file ‘C:\inetpub\wwwroot\MyWeb\Resources$temp_f2ad35fc-4346-4c6f-bb83-cdf8e52c0697.rdlx’

    Location of report is ‘C:\inetpub\wwwroot\MyWeb\Designer$temp_f2ad35fc-4346-4c6f-bb83-cdf8e52c0697.rdlx’

    Best,

    Goran

  • Posted 28 November 2019, 5:06 pm EST

    Hello Goran,

    I have checked on two-three machine, it is working fine at my end. Could you do the exact same steps which I have given in the previous reply with WebDesigner_MVC(Core) product sample?

    Please do not change anything in the script or controller.cs. Just do the changes that I mentioned in the steps.

    Also, you need to change the “FileStore” in startup.cs if you want the designer to look into a different folder.

    app.UseDesigner(config => config.UseFileStore(ResourcesRootDirectory));
    

    Thanks,

    Mohit

  • Posted 6 December 2019, 1:25 am EST

    Hi Mohit,

    We don’t understand each other at all. Report from the designer cannot work because the viewer-container.js script call options.makeViewerUrl(). The options object doesn’t have this function so it simply cannot work.

    We did not understand each other on next problem too. Clearly I put designer to look into a different folder than report. Otherwise I will not have this problem. My question is why I have this problem?

    My code is:

    app.UseReporting(config => config.UseFileStore(ResourcesRootDirectory))

    app.UseDesigner(config => config.UseFileStore(DesignerRootDirectory))

    When I debug all AR scripts (it not normal than I have to do that) I still get error that designer cannot find report on folder belongs to report (ResourcesRootDirectory), but not designer (DesignerRootDirectory)!

    Probably we use different versions. My version is ActiveReports-v13.2.18663.0.msi

    Best,

    Goran

  • Posted 9 December 2019, 10:45 pm EST

    Hello Goran,

    Sorry for all the confusion and delay.

    What I understood from this:

    1: Issue is not related to deployment

    2: You have the two directories ResourcesRootDirectory and DesignerRootDirectory that you are using in the following way:

    app.UseReporting(config => config.UseFileStore(ResourcesRootDirectory))
    app.UseDesigner(config => config.UseFileStore(DesignerRootDirectory))
    

    Due to this, you get the error “XXX report is not found in ResourcesRootDirectory” while previewing the report in the designer.

    3: Because of this error, you want to customize the “options.makeViewerUrl()” to overcome this problem.

    Request to please confirm if we are on the same page now or not?

    Thanks,

    Mohit

  • Posted 10 December 2019, 2:35 am EST

    Hi Mohit,

    That is right. Now this is my major problem. I’ve workaround deployments problems changing AR scripts (I don’t like this solution but it’s OK until you fix it). But now my major problem is designer (you describe problem well). I can see and edit reports, but I cannot run them.

    Actually I have to change the options.makeViewerUrl() function because this function doesn’t exist. I found out how to set design time location of the report (I have to change AR scripts too), but not run time location. Right now I have to switch to the previous version (ActiveReports-v13.0.15823.0.msi) because in this version deploying works fine. I don’t understand that you cannot just check what you did wrong between the first version and SP1?

    Best,

    Goran

  • Posted 12 December 2019, 8:00 pm EST

    Hi Goran,

    Please give us some time to investigate on this. Will get back to you.

    ~Pragati

  • Posted 15 December 2019, 11:40 pm EST

    Hello Goran,

    I am extremely sorry for the delay as I was on leave. Sorry, I am a little bit confused. the problem occurs with the different directory is also occurred on the initial build of AR13.

    When you create a new report and try to preview the report then the designer service saved the temporary report in the DesignerRootDirectory, after that report service looks the temporary report in the ResourcesRootDirectory (as you give different directory name). Hence, report service show error as the temp report is only present in the DesignerRootDirectory folder.

    There is one solution for that, you can create a custom report service to control the temp saved path. Please refer to the following files to implement the same.

    Startup.zip

    I don’t understand that you cannot just check what you did wrong between the first version and SP1?

    In our deployment working fine on the latest build. Could you please drop your sample(which is working with the initial build but not with the latest build) at the following link so that I can check the difference of both versions.

    https://www.dropbox.com/request/Dk2lzHpzo2wpnCTHSZ2L

    Thanks,

    Mohit

  • Posted 18 December 2019, 3:23 am EST

    Thanks Mohit, with this code I have better control, but I still have the same problem The viewer looks for report in the wrong folder (folder assign by this line: app.UseReporting(config => config.UseFileStore(ResourcesRootDirectory)). I will use the same folder for the designer and the viewer and I hope it will be fine for my client. If you fix this just let me know.

    I have found workaround for deploy problems (I have to change jsViewer.min.js, baseServerApi.js and viewer-container.js files). I can live with that.

    You can reproduce this problem with sample JSViewer_MVC(Core)

    1. Open sample in Visual Studio 2019
    2. Publish project to the folder
    3. Open IIS, right click on Default web site, from Deploy choose Import application…
    4. If you use the first version everything is fine. With other you will not be able to open report (AR cannot find file). You can workaround this problem if you hardcode your web app name in the jsViewer.min.js script.

    Right now I can live with those problems, but I will be happy if you solve problems in the future.

    Best,

    Goran

  • Posted 18 December 2019, 8:09 pm EST

    Hello Goran,

    Have you changed the save report path in the “SaveReport” method like as follow:

    
    public string SaveReport(string name, Report report, bool isTemporary = false)
            {
    
                var reportName = isTemporary
                             ? $"{Guid.NewGuid().ToString("D")}.rdlx"
                             : GetReportResourceName(name);
    
                report.Name = name;
    
                if (isTemporary)
                {
                    reportName = $"{TempReportPrefix}{reportName}";
                    _[b]rootFolder = new DirectoryInfo(String.Format(@"{0}.\resources\", HttpRuntime.AppDomainAppPath));[/b]
                }
    
                var reportFullPath = Path.Combine(_rootFolder.FullName, reportName);
    
                var dirPath = Path.GetDirectoryName(reportFullPath);
                if (!Directory.Exists(dirPath))
                {
                    Directory.CreateDirectory(dirPath);
                }
    
                byte[] reportXml = ReportConverter.ToXml(report);
    
                var absoluteReferences = ReportResources.GetReferences(reportXml);
    
                var reportFullUri = new Uri(reportFullPath);
                var referencesMap = new Dictionary<string, string>();
                foreach (var resourceAbsolutePath in absoluteReferences)
                {
                    if (!IsValidPath(_rootFolder.FullName, resourceAbsolutePath)) continue;
                    if (!TryUpdateRelativePath(_rootFolder.FullName, reportFullPath, resourceAbsolutePath, out string resourceRelativePath)) continue;
    
                    referencesMap.Add(resourceAbsolutePath, resourceRelativePath);
                }
                var updReportXml = ReportResources.UpdateReferences(reportXml, referencesMap);
    
                File.WriteAllBytes(reportFullPath, updReportXml);
    
                var reportId = GetResourceId(reportName.Replace('\\', '/'));
    
                return reportId;
            }
    
    

    Also, if you changed the report save path then you need to change the relative path of all resources which have been used in the report as all are located in DesignerRootDirectory folder.

    Sorry, Still I am not able to reproduce the issue at my end. Please refer to the attached video. Request to please confirm If I am missing something.

    https://www.dropbox.com/s/n3llcpg3e8vlokh/2019-12-19%20at%2014-29-54.mp4?dl=0

    Thanks,

    Mohit

  • Posted 15 January 2020, 8:41 am EST - Updated 30 September 2022, 6:40 am EST

    Hi Mohit,

    Finally I’ve decided to keep prepared reports and designer reports on the same folder. I can live with this. But now I have much bigger problem. Printing and all exports from jsViewer.js and from designer works fine on my computer (on this computer ActiveReports are licensed). When we install our application on IIS with the same settings on other computers printing and export don’t work. The error 500 occurs, the picture below shows this error. I need solution as soon as possible.

    I have tried all browsers and I have the same problem.

    My version is ActiveReports-v13.2.18663.0

    Best,

    Goran

  • Posted 15 January 2020, 7:50 pm EST - Updated 30 September 2022, 6:40 am EST

    Hello Goran,

    I have tested at my end and found no issue. Printing and Exporting work perfectly. Please refer to the attached image.

    Please make sure that you set permission (read) for ([computer_name]\IIS_IUSRS) to: published folder, folder with reports and folder with databases.

    Also, you have .Net core 2.1 hosting bundle install on other machines.

    Thanks,

    Mohit

  • Posted 16 January 2020, 1:41 am EST

    Hi Mohit,

    Without .Net core 2.1 hosting bundle I would not be able to run the application. Without user rights I would not be able to run reports in the designer!

    I have the same configuration on all computers. I deploy application from the same zip file (Web deploy package created by Visual Studio 2019), I have the same application pool, with the same application pool identity (actually I have tried all kind of identity but it doesn’t work), only difference is that my PC run Windows 7 others different server versions (2012 and 2016) and Windows 10. This error occurs on the server side with error 500. The source is more less yours samples (JSViewer_MVC(Core) and WebDesigner_MVC(Core) ) with same binaries. All other ActiveReport functionality work same on all computers.

    I have impression that you did not test your product on this usage scenario (by the way very common scenario). I have to change your java script files just to run the reports. You always say that you cannot reproduce problems I have. Even when the bug is obvious like calling non existing function in the javascript file. I can send e-mail with link to zip file with application and the database. You only need to deploy app and restore database. Than when you get my source you will be able to reproduce problem.

    Probably this problem is connected with licensing. It is strange that printing and exporting work only on the computer with ActiveReport license.

    Best,

    Goran

  • Posted 16 January 2020, 8:01 pm EST

    Hello Goran,

    I have created a new case on S1 our Private Forum so that you can share your personal data with us,

    https://supportone.componentone.com/home/casedetail/417460

    You can log in to the above link with the same forum credential.

    Thanks,

    Mohit

  • Posted 17 January 2020, 5:04 am EST - Updated 30 September 2022, 6:40 am EST

    Thanks Mohit,

    I can sign in to the private forum. I found out what is the problem. Some library are missing. When I install ActiveReport on the computer exporting and printing works. In the project I have the same dependencies as sample project (jsViewer Core and designer Core, see picture below). Now it is not urgent at all, but when you find some time please check this out.

    I have few smaller problems, but nothing important. I will report them later.

    In spite some problems Active report is great product.

    Best,

    Goran

  • Posted 19 January 2020, 6:13 pm EST

    Hello,

    Thanks for the appreciation.

    I am glad that you solved your problem. Please share the problem that you are facing. I would be more than happy to help you.

    I suggest you to please open a new case here or on our private forum as this thread is getting very long.

    Thanks,

    Mohit

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels