Search code examples
javascriptextjsextjs4

How to create an Ext.data.Model from a generic object?


I want to create a real Ext.data.Model record that could be loaded later into a form from values held in an object.

Is this possible ?

The issue is that I have a grid which holds actual Ext.data.Model objects, that I load into a form, but some logic in my form renders the form again, clearing all form values and loading the record once again.

Thing is that the user will lose all changes when this logic is performed. So I'm thinking of using the form's getValues() which returns an object, recreate an Ext.data.Model and then load it again in the form.

Any ideas if this is possible ?

Thanks.


Solution

  • I ended up doing this:

    var record = Ext.create('ModelName');
    record.data = form.getValues();
    

    This creates a record loadable into a form.