1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    15
    Vote Rating
    1
    sergiob is on a distinguished road

      0  

    Default Custom component problem

    Custom component problem


    It seems that I have a problem: I have several Sencha Architect projects and I want to use component from one project in another project. I don't want to import that component because I don't want update that component simultaneously in two projects. I just want to use that component by xtype. But I can't do that because any component in project should have its xtype, and the xtype should point to default component or custom component in that project, and can not be modified. I want to use xtype that is not visible
    I fixed this with a hack in Sencha Designer 2-beta: I've added "extend" as a custom property and there were 2 properties with name "xtype" and the second one was used. Now Sencha Architect does not allow such things and still does not allow to modify xtype. How can I resolve the problem? Please, help!

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,369
    Vote Rating
    128
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    That was definitely a hack. Some browsers would choke on the fact you had two keys defined of "xtype".

    We're aware of the need to share components between projects and working on a solution for you.

    One thing that we've discussed doing in the near future is creating a prepareConfig method that would allow you to modify your config via a function.

    Or perhaps as an expansion to that it could be a designer specific configuration on every child item/instance that would pass the config individually to its own method.

    In the interim, I can't think of a particularly elegant solution for you other than overriding the class via an override.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha User
    Join Date
    May 2011
    Posts
    15
    Vote Rating
    1
    sergiob is on a distinguished road

      0  

    Default


    I've already thought about that. You can override a class, but the "extend" property will not work in the the override.
    Code:
    Ext.define('VCube.view.XXX', {
        extend: 'Ext.panel.Panel', ...
    Code:
    Ext.define('VCube.view.override.XXX', {
        requires: 'VCube.view.XXX'
    }, function() {
        Ext.override(VCube.view.XXX, {
            extend: 'VCube.custom.YYY',
            initComponent: function() {
                var me = this; // me.superclass is Panel, not YYY :-(

  4. #4
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,369
    Vote Rating
    128
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    xclass might actually work. I'm not sure whether it has priority over xtype or not.

    It might trigger problems though. The reason we don't permit users to add certain configurations as custom configs/properties is that they can cause runtime errors when we try to display them on the canvas.

    This is part of the reason why anything that goes inside an override is not evaluated and will not be reflected in the canvas.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

Thread Participants: 1