Completed
Last Updated: 17 Aug 2023 19:34 by Andy
Release 2.25.0
Wei
Created on: 17 Mar 2021 07:32
Category: Grid
Type: Feature Request
3
OnNeedModel event to fire before OnEdit, before item insertion and before filtering where I can provide my own model instance

I want to be able to use interfaces and models that are created from a service when working with the grid. A parameterless constructor is not enough for me, I need to be able to instantiate models in a more complex manner.

---

ADMIN EDIT

The tentative event name I have put in the title might vary when the implementation is researched. The goal would still be the same - the grid to provide an event when it needs an instance of the model so you can provide it with one. At the moment this happens when a row enters edit mode, when the filter list needs to be built, and when you are inserting an item (a caveat with the last one might be the OnClick event for the command button - the new event might have to fire before OnClick so it can give you the model).

---

3 comments
Andy
Posted on: 17 Aug 2023 19:34
Nate's comment seems to be correct and could use addressing.
ADMIN
Dimo
Posted on: 21 Jul 2022 08:28

Hi Nate,

If the Grid is bound to a collection of MyModels, then the OnModelInit event expects a new MyModel instance. If you want to prepopulate a child MySubModel instance as well, you can do it in this same handler.

Here is a runnable REPL page. If your scenario is different and believe the Grid behaves incorrectly, please send us a modified version of the example in a separate forum thread or a ticket. This page is dedicated to the feature request status only.

Regards,
Dimo
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Nate
Posted on: 14 Jul 2022 19:49

The OnNeedModel seems to only work for models containing only basic properties.  On a model like the one below the grid is still calling the parameterless construction on MySubModel class.

 

 

class MyModel{

  public string Prop1{get;set;}

  public MySubModel Prop2{get;set;}

}

class MySubModel{

  public string Prop3{get;set;}

}