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

Telerik Q3 2013 HTML5 Report Viewer using Ninject

7 Answers 112 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Matt Miller
Top achievements
Rank 1
Matt Miller asked on 18 Oct 2013, 06:47 PM
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?


7 Answers, 1 is accepted

Sort by
0
Ignacio
Top achievements
Rank 1
answered on 18 Oct 2013, 08:28 PM
Could you please provide your controller class (especially the constructors) and your relevant Ninject modules?
0
Matt Miller
Top achievements
Rank 1
answered on 18 Oct 2013, 08:37 PM
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.
0
James
Top achievements
Rank 1
answered on 10 Jun 2014, 07:55 PM
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?
0
Matt Miller
Top achievements
Rank 1
answered on 11 Jun 2014, 03:43 PM
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");


0
Matt Miller
Top achievements
Rank 1
answered on 11 Jun 2014, 03:45 PM
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 
0
James
Top achievements
Rank 1
answered on 11 Jun 2014, 04:26 PM
Excellent.  I'll give it a try.  
Thanks 
Jamie
0
Stef
Telerik team
answered on 12 Jun 2014, 11:51 AM
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.

 
Tags
General Discussions
Asked by
Matt Miller
Top achievements
Rank 1
Answers by
Ignacio
Top achievements
Rank 1
Matt Miller
Top achievements
Rank 1
James
Top achievements
Rank 1
Stef
Telerik team
Share this question
or