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

Programmatically create row item/model

2 Answers 187 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jens
Top achievements
Rank 1
Jens asked on 22 Apr 2020, 03:35 PM

I use a MVVM approach to populate the Grid. The rows are actually viewmodels keeping state. They have no parameterless constructor, they are created by factory methos using injected services. The Grid creates the item before assigning it to the event args passed to the handler method. 

In my case "No parameterless constructor defined for type '...' is thrown. How can I have control on the creation of my row models?

2 Answers, 1 is accepted

Sort by
0
Jens
Top achievements
Rank 1
answered on 23 Apr 2020, 05:43 AM
Ok, I see that one can override the default behaviour while creation (and other actions) with GridState. My post has been a little premature.
0
Marin Bratanov
Telerik team
answered on 23 Apr 2020, 09:25 AM

Hello Jens,

Indeed, a parameterless constructor is needed, and the state is a valid solution to this. I have added this to the documentation in the Notes section https://docs.telerik.com/blazor-ui/components/grid/columns/bound#notes

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Grid
Asked by
Jens
Top achievements
Rank 1
Answers by
Jens
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or