ASP.NET MVC ReportViewer shows empty content

3 posts, 0 answers
  1. Jose
    Jose avatar
    8 posts
    Member since:
    Jan 2017

    Posted 22 Mar 2017 Link to this post

    Hi,

    we are new on Telerik Reporting, basically in this moment we are testing the tool and try to decide if we replace SSRS. we are using the Telerik MVC Reportviewer for ASP.NET MVC (Reporting R3 2016) and we set a couple elements configuration in order to use this tool, everything looks good (apparently), but when the application host calls the ReportViewer and try to render the content, nothing happen, basically the report viewer control is showed but the content inside it not.

     

    Here our configuration:

    1. DAO Object:

        [DataObject]
        public class DIAS_FESTIVO : BASE
        {
            public int ID_FESTIVIDAD { get; set; }
            public string EVENTO_FESTIVO { get; set; }
            public string FECHA_FESTIVIDAD { get; set; }
            public bool ES_DIA_HABIL { get; set; }

            public DIAS_FESTIVO(string strConexion, string strNombreApp)
            {
                this.strConexion = strConexion;
                this.strNombreApp = strNombreApp;
            }
            public DIAS_FESTIVO()
            {
            }

            [DataObjectMethod(DataObjectMethodType.Select)]
            public List<DIAS_FESTIVO> getListDIAS_FESTIVOS()
            {
                List<DIAS_FESTIVO> DIAS_FESTIVOS = new List<DIAS_FESTIVO>();
                DataTable dt = new DataTable();
                try
               {

                    strConexion = "Data Source=XXXX;User ID=XXX;Password=YYYY;Unicode=True";        

                    Database db = new Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase(strConexion);
                    OracleDbType cursor = OracleDbType.RefCursor;
                    DataSet oDataSet = db.ExecuteDataSet("MI_PKG.ObtenerDiasFestivos", cursor);
                    dt = oDataSet.Tables[0];

                    //On this point the data has been extracted, we have debugged this part and see the information, after the query is solved we convert the datatable into collection
                    DIAS_FESTIVOS = DataTableToList<DIAS_FESTIVO>(dt);

                }
                catch (Exception ex)
                {
                    throw ex;
                }

                return DIAS_FESTIVOS;
            }

    }

     

    2. We set a Custom Report Resolver class in order to handle the request to fill the report datasource, here is:

        public class CustomReportResolver : Telerik.Reporting.Services.Engine.IReportResolver
        {
            public Telerik.Reporting.ReportSource Resolve(string reportId)
            {
                ObjectDataSource oDs = new ObjectDataSource();
                oDs.DataSource = typeof(DIAS_FESTIVO); //Indicate the collection to use
                oDs.DataMember = "getListDIAS_FESTIVOS"; //the method to extract the collection on the point #1
                oDs.Name = "Report1.trdp"; //This is the name of the report, previously created on the Telerik Report designer
                
                Report rpt = new Report();
                rpt.DataSource = oDs;
                rpt.Name = "Report1.trdp";            
                rpt.Visible = true;

                return new Telerik.Reporting.InstanceReportSource { ReportDocument = rpt };
            }
        }

     

    3. On View cshtml (partial view)

    @model Telerik.Reporting.ReportSource
    @using NEW

    <style>
        #reportViewer1 {
            position: relative;
            width: auto;
            height: 500px;
            font-family: Verdana, Arial;
        }
    </style>

    @(Html.TelerikReporting().ReportViewer()
            .Id("reportViewer1")
            .ServiceUrl(Url.Content("/api/reports"))
            .ReportSource("1")
            .ViewMode(ViewMode.Interactive)
            .ScaleMode(ScaleMode.Specific)
            .Scale(1.0)
            .PersistSession(false)
            .PrintMode(PrintMode.AutoSelect)
    )

     

    4. WebConfig file in application host has been set, 

      <configSections>

        <section name="Telerik.Reporting" type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting" allowLocation="true" allowDefinition="Everywhere" />
      </configSections>

     

      <Telerik.Reporting>
        <assemblyReferences>
          <add name="DAO" version="1.0.0.1"/>
        </assemblyReferences>
      </Telerik.Reporting>

    DAO is the project class c# you see in the point #1

     

    Please see the attached image: ReportViewer_Loaded.png in order to see the result when the page has been loaded.  I am pretty sure that the code into DAO object is executed when the application is running because we debugged that part, but I suspect the problem is when we try to bind the template dataset into report with the datasource (dataset included) passed as parameter (I mean the collection object as you see in the point #1) because when we test the template report (Report1.trdp) from Telerik Report design the data appear, in that moment the connection is directly on oracle database.

     

    Please your help,

    Many Thanks,

  2. Katia
    Admin
    Katia avatar
    693 posts

    Posted 24 Mar 2017 Link to this post

    Hi Jose,

    From what you've shared we see that there is a data layer and in custom resolver the data is correctly connected to ObjectDataSource component.

    In custom resolver, check if this code creates a new instance of the report you designed or it creates a base class Telerik.Reporting.Report:
    Report rpt = new Report();
    In general, it is recommended to name report classes other that "Report" to avoid confusions.

    Another suggestion is to check if the report uses data items such as Table (CrossTab, List) to show the data. If yes, those data items will not reuse the report's data source automatically and you need to set their DataSource properties as well.
    At design-time, you can reuse the report's data source for the inner data item with bindings. At runtime, you can use Report.Items.Find method to get the child items.

    If the above sugegstions do not help we would need some additional information in order to tell where exactly the issue is. You can attach the project demonstrating your current settings in a support ticket.


    Regards,
    Katia
    Telerik by Progress
    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
  3. Jose
    Jose avatar
    8 posts
    Member since:
    Jan 2017

    Posted 27 Mar 2017 in reply to Katia Link to this post

    Whooopsss! basically that was the problem. Thanks for your help!
Back to Top