PDA

View Full Version : [FIXED] Mixins property is not available and cannot be added



markofsine
12 Feb 2012, 4:58 AM
How can the mixins property be added to a class?

It currently does not exist in Component Config and cannot be added as the 'Add' function only adds string values and not object or array.

Thanks.

crispthinking
17 May 2012, 5:16 AM
We're also in need of this. Any idea if this is on the roadmap, or why it's not possible?

abcoa
31 May 2012, 8:52 AM
Yes - this is very much needed!

dmulcahey
31 May 2012, 2:49 PM
If you supply a value when you add the custom option it may work... Ex:

Type in: mixins:['something']
Then click "add"

abcoa
31 May 2012, 3:03 PM
If you supply a value when you add the custom option it may work... Ex:

Type in: mixins:['something']
Then click "add"

That didn't work...
You get a message "A custom config cannot override a reserved member"

dmulcahey
31 May 2012, 3:19 PM
Gotcha. You could probably use an override to take care of it in that case. But the method described above will let you control the type of custom properties that aren't reserved.

abcoa
1 Jun 2012, 5:46 AM
Gotcha. You could probably use an override to take care of it in that case. But the method described above will let you control the type of custom properties that aren't reserved.

That is true but at the same time there are so many 'restrictions' in SA 2 that I find my self writing overrides constantly....

Can't add mixins, override
Can't use variable name where SA 2 expects a number, override (e.g. Store where pageSize is variable)
Can't mess with constructor, override
Can't add feature to your grid, override


I know Sencha is aware of these issues with SA 2 and (I am hoping) they will address them, but for now, using SA 2 for more complex apps is a bit of a struggle...

pmarko
5 Jun 2012, 7:11 AM
+1

JoelRSimpson
25 Jun 2012, 8:11 PM
I'm trying to add mixins via an override so that I can create functionality similar to the ImageViewer example (my app is a workflow engine, the icons are workflow nodes). I have not found a way to successfully add the mixins definition.

mixins: { dragSelector: 'Ext.ux.DataView.DragSelector',
draggable : 'Ext.ux.DataView.Draggable'
},

I'm starting to understand that this might be an order of events kind of problem, and might not be possible currently, but it's very frustrating that adding these to the generated class by hand makes everything work just fine. If architect simply had a standard field that would allow me to specify the array it would be enough.

Does anyone know how to add mixins via an override? I've tried many different ways and if they do get added, it replaces the other mixins rather than adding them.

apsq
1 Aug 2012, 9:19 AM
This may be a bit late, but: it's impossible to add mixins in an override because mixins are resolved on definition rather than on instantiation (they're not part of the configuration, they're part of the definition itself).

The only way to override mixins is by adding an internal property (say, 'x-mixins') and overriding Ext.define to parse that property and add any mixins to the mixin property before doing the regular Ext.define dance. Because SA2 helpfully (*cough*) throws all non-scalar values in the initComponent method rather than the definition, the internal property needs to be a string rather than an array. I've used a comma as separator and just call split() on the value to turn it into an array, but you may find other approaches useful (worst case: enter JavaScript code that you want to be eval'ed; not-so-bad case: use JSON).

aconran
1 Aug 2012, 11:25 AM
In the next minor version you will be able to define mixins and it will go on the read-only class.

sergiomichels
3 Jul 2013, 6:24 AM
I'm using Sencha Architect v 2.2.2 and still cannot set the property. Am I missing something here?