Telerik Q3 2013 HTML5 Report Viewer using Ninject

8 posts, 0 answers
  1. Matt Miller
    Matt Miller avatar
    23 posts
    Member since:
    Jan 2012

    Posted 18 Oct 2013 Link to this post

    I'm trying to use the new html5 report viewer using the example given here HTML5 Report Viewer with MVC .

    Whenever i try to call the controller class from the example , i get this error:

    The IControllerFactory 'CNX.WebUI.Infrastructure.NinjectControllerFactory' did not return a controller for the name 'MenuReport'.

    Does Telerik have any tutorials on how to use this new report viewer in conjunction with Ninject?


  2. nikobellic
    nikobellic avatar
    46 posts
    Member since:
    Feb 2013

    Posted 18 Oct 2013 Link to this post

    Could you please provide your controller class (especially the constructors) and your relevant Ninject modules?
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Matt Miller
    Matt Miller avatar
    23 posts
    Member since:
    Jan 2012

    Posted 18 Oct 2013 Link to this post

    The report controller is basically as from the previously mentioned tutorial other than i am return an IReportResolver in the action method: 

    public class MenuReportController : ReportsControllerBase
    {
        public MenuReportController()
        {
             
          
        }
     
        public IReportResolver ReportMenuAction()
        {
            return CreateReportResolver();
        }
     
        protected override IReportResolver CreateReportResolver()
        {
            var reportsPath = HttpContext.Current.Server.MapPath("~/Reports");
            return new ReportFileResolver(reportsPath).AddFallbackResolver(new ReportTypeResolver());
        }
     
        protected override ICache CreateCache()
        {
            return CacheFactory.CreateFileCache();
        }
    And here is my ninject code:

    public class NinjectControllerFactory : DefaultControllerFactory
        {
            private IKernel ninjectKernel;
            public NinjectControllerFactory()
            {
                ninjectKernel = new StandardKernel();           
                AddBindings();          
            }      
     
            protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
            {
                return controllerType == null ? null : (IController)ninjectKernel.Get(controllerType);           
            }
     
            private void AddBindings()
            {           
                ninjectKernel.Bind<IUserViewRepository>().To<EFUserViewRepository>(); 
                ninjectKernel.Bind<IRoleRepository>().To<EFRoleRepository>();
                ninjectKernel.Bind<IAuthentication>().To<AuthenticationProvider>();
                ninjectKernel.Bind<IPendingTrainRepository>().To<EFPendingTrainRepository>();
                ninjectKernel.Bind<IRailCarT94Repository>().To<EFRailCarT94Repository>();
                ninjectKernel.Bind<IPendingEDI417Repository>().To<EFPendingEDI417Repository>();
                ninjectKernel.Bind<IRailCarEDIRepository>().To<EFRailCarEDIRepository>();
                ninjectKernel.Bind<IMatchedT94EDI417Repository>().To<EFMatchedT94EDI417Repository>();
                ninjectKernel.Bind<IMatchedT94EDI417RailCarRepository>().To<EFMatchedT94EDI417RailCarRepository>();
                ninjectKernel.Bind<IT94EdiMatchesRepository>().To<EFT94EdiMatchesRepository>();
                ninjectKernel.Bind<IPendingSap2KssHeaderRepository>().To<EFPendingSap2KssHeaderRepository>();
                ninjectKernel.Bind<IPendingSap2KssDetailRepository>().To<EFPendingSap2KssDetailRepository>();
     
                //new ui bindings
                ninjectKernel.Bind<IEdiTrainRepository>().To<EFEdiTrainRepository>();
                ninjectKernel.Bind<IEdiRailcarRepository>().To<EFEdiRailcarRepository>();
                ninjectKernel.Bind<IT94TrainRepository>().To<EFT94TrainRepository>();
                ninjectKernel.Bind<IT94RailcarRepository>().To<EFT94RailcarRepository>();
            }
        }

    The ninject code works fine for any of my other controllers. But they inherit from standard controller class, where as the report controller inherits from ReportsControllerBase.
  5. James
    James avatar
    5 posts
    Member since:
    Apr 2011

    Posted 10 Jun 2014 in reply to Matt Miller Link to this post

    Matt, I assume you're following this post and if you've received the solution to using Ninject with ReportViewer, I desperately need it.  If you haven't... why, are we the only 2 guys with this combination of software?
  6. Matt Miller
    Matt Miller avatar
    23 posts
    Member since:
    Jan 2012

    Posted 11 Jun 2014 in reply to James Link to this post

    I never actually did.
    I have a "Reports" item on my applications main menu.
    When the user clicks that item, i load a view with a drop down of all reports in my \Reports directory, and a "View Report" button.
    When they click this button , i load the report viewer into a popup window.

    Here's the definition of the div containing my report viewer object: 
    <div id="ReportWindow">     
         @(Html.TelerikReporting().ReportViewer()
              .Id("reportViewer1")
              .ServiceUrl("/api/reports/")
              .TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate.html")
              .ViewMode(ViewModes.INTERACTIVE)
              .ScaleMode(ScaleModes.SPECIFIC)
              .Scale(1.0)
              .PersistSession(false)
                   )
      </div>

    In $(document).ready() function i have this to init the window:
    var win = $("#ReportWindow").kendoWindow({          
                actions: ["Maximize", "Minimize", "Close"],
                draggable: true,
                height: "500px",
                width: "500px",
                modal: true,
                resizable: true,           
                visible : false ,
                position: { top: 100, left: 100 }
            }).data("kendoWindow");


  7. Matt Miller
    Matt Miller avatar
    23 posts
    Member since:
    Jan 2012

    Posted 11 Jun 2014 in reply to Matt Miller Link to this post

    Sorry , forgot my click handler for the button itself : 

    $("#showWindow").click(function () {
               var win = $("#ReportWindow").data("kendoWindow");
               //var train = $("#trainList").data("kendoDropDownList");
               var report = $("#reportList").data("kendoDropDownList");
               //var start = $("#startDate").data("kendoDateTimePicker").value();
               //var end = $("#endDate").data("kendoDateTimePicker").value();
               var reportViewer = $("#reportViewer1").data("telerik_ReportViewer");
     
               // alert('start: ' + start.toDateString() + ' end: ' + end.toDateString() + ' aut: ' + train.value());
               reportViewer.reportSource({
                   report: report.text() + ".trdx"//,
                   // parameters: { startDate: start.toDateString(), endDate: end.toDateString(), AUT: train.value() }
               });
     
               //if (train.text().trim() == "") {
               //    alert('Please select train.');
               //}
               //else {
               reportViewer.refreshReport();
               // win.title(report.text() + ' -- ' + train.text());
               win.title(report.text());
               win.center();
               win.open();
           });
            
       });


    Hope that helps 
  8. James
    James avatar
    5 posts
    Member since:
    Apr 2011

    Posted 11 Jun 2014 in reply to Matt Miller Link to this post

    Excellent.  I'll give it a try.  
    Thanks 
    Jamie
  9. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 12 Jun 2014 Link to this post

    Hello,

    I am glad to see you both found a solution for your scenarios.

    If you need any further help, feel free to use our support ticketing system to send us demo projects that illustrate the problem, so we can check it.

    Regards,
    Stef
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready