PDA

View Full Version : Help with class system



Syndicate
9 Apr 2014, 4:11 AM
I have noob question.

How can i define init params and methods for my class.



// class for remote grid, where i want describe init params
Ext.define('MyApp.view.GridRemote', {
extend: 'Ext.grid.Panel',

store: {
pageSize: 5,
autoLoad: false,
remoteSort: true,
remoteFilter:true,
autoSync: true
}

});

// here i want use this init params
Ext.define('MyApp.view.Responses', {
extend: 'MyApp.view.GridRemote',
alias : 'widget.responses',
initComponent: function () {......

slemmon
15 Apr 2014, 12:04 AM
As written I would expect MyApp.view.Responses to inherit the store config from MyApp.view.GridRemote. Perhaps you can share a more complete test case at https://fiddle.sencha.com to demonstrate the setup?

Syndicate
16 Apr 2014, 12:12 PM
Thank you!

Some example https://fiddle.sencha.com/#fiddle/55c
Here i want to set all instances property autoLoad, defaults and event load.

In real situation i have 10-15 grids with same parametrs, methods and events (for store, proxy etc). What is right case to do this?

slemmon
16 Apr 2014, 3:52 PM
You can define a store class to be used by your components and the store definition can have an alias which will allow you to then instantiate the store by config - passing in additional configs as needed per grid instance.

See the example here:

55m

Syndicate
16 Apr 2014, 8:51 PM
Thank you. I understand.

In you example propery flex doesnt apply to instance. How be with this?

slemmon
17 Apr 2014, 11:01 AM
Hi,

Columns will be a little different in that you can't define a columns class and apply configs to it per instance like you can with a store. The way you would work with column defaults would be to do something like in the example below within the initComponent function.

56f