PDA

View Full Version : Create reusable component



marxan
29 Jun 2015, 11:50 PM
Hello,

I'm using Extjs 4.2 withount Mvc. I have created a combo and I would like to use in different panels.


CdmStore = new Ext.data.Store({
fields: [{
name: 'l_cdm'
}, {
name: 'c_cdm'
}],
remoteFilter: true,

// autoSync: true,
//autoLoad: true,
proxy: {
type: 'ajax',
url: 'data/comboTypeMan.cfc?method=getAgent',
reader: {
type: 'json',
root: 'data'
}
}
});

cdmManLib = Ext.create('Ext.form.ComboBox', {
store: comboCdmStore,
labelAlign: 'top',
fieldLabel: 'Chef de manoeuvre',
queryMode: 'remote',
selectOnFocus: true,
name: 'cdmManLib',
minChars: 2,
typeAhead: true,
editable: true,
width: 270,
valueField: 'l_cdm',
displayField: 'l_cdm'
});

I was thinking to use Ext.define ... but I think this is work only with the MVC as we use the app name in the define path. However, I do not have an application name in my no MVC app.

Anyone could give me a clue how to achieve it?

Thanks in advance,

tristan.lee
30 Jun 2015, 11:09 AM
There's no need to worry about using the MVC pattern or not, you were on the right track with Ext.define. Here's an example where I defined your component with an xtype of customcombo, and then I can reference that within the form items:

pmh