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

Replace Grid Entity Factory Method with Call to Dependency Injection Container

3 Answers 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 30 Aug 2018, 09:07 PM

Hi, is there a way to specify using the .Net Core Dependency Injection container instead of constructing an entity directly by the Grid?

For instance, I would like to specify the interface of the Entity to request from the DI container as below:

@(Html.Kendo().Grid<IEntityInterface>()

When I click add new it throws an exception saying it cannot create an instance of the interface, which of course is correct, I would like it to request an instance from the DI container instead.

Is this possible?

Thanks!

3 Answers, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 04 Sep 2018, 10:03 AM
Hi Robert,

Setting the Grid model to an interface is not possible and if there will be some dynamic data in your scenario, a possible solution is to use DataTable or any other collection that will hold the information about the columns and build the Grid configuration dynamically as shown in the following HowTo article:
Hope this helps.


Regards,
Konstantin Dikov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Robert
Top achievements
Rank 1
answered on 04 Sep 2018, 03:08 PM

It seems to mostly work however, with the above stated notable exception. Is this a scenario you can add to your testing? Programming to an interface is quite common, the real issue we have is the factory method not pointing at the Core DI container. Could this all be added as a future improvement?

Thanks!

0
Konstantin Dikov
Telerik team
answered on 07 Sep 2018, 08:55 AM
Hi Robert,

You can create a feature request in our public portal and if it receives enough votes from the community, it will be considered for future releases:

Kind Regards,
Konstantin Dikov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Robert
Top achievements
Rank 1
Share this question
or