Reference a Model from a Store in ExtJS using alias


In this below Model, how to Reference a Model from a Store in ExtJS using alias?

Ext.define('MyAPP.model.myMod', {
   extend  : 'Ext.data.Model',
   alias   : 'model.myMod',
});

And a store:

   Ext.define('MyAPP.store.MyStore', {
      extend : 'Ext.data.Store',
      model  : 'MyAPP.model.myMod',
});

Actually, We cannot reference the model on the store using the alias. In general, we must use full path: MyAPP.model.myMod.

BUT…

, We can use the property alternateClassName for your Model, like this:

Ext.define('MyAPP.model.myMod', {
   extend  : 'Ext.data.Model',
   alternateClassName : 'myMod',
});
Ext.define('MyAPP.store.MyStore', {
      extend : 'Ext.data.Store',
      model  : 'myMod',
});

Now, you’re able to reference using only model: 'myMod' from your Store. No need to reference it using full path: MyAPP.model.myMod.

-Ref my answwser in stackoverflow: https://stackoverflow.com/a/68891104

Nam Le.


Leave a Reply