Results 1 to 7 of 7

Thread: How to remove Child Component on Parent Component init with controller init

  1. #1

    Default How to remove Child Component on Parent Component init with controller init

    How do i remove some component on parent init within controller init listener.
    ive try to use render: raise some error on addCls etc.
    using afterrender: there is no component selected, so unable to remove/destroy it.
    using show: i need to apply in form, and this way doesnt work wihtout triggering show method

    i use it to prevent create child component for some case on parent create.
    so what should i do to make it work?

    here is my sample code
    Code:
    // part of controller code
    init: function(){
        this.control({
            "container#parent":{
                someevent: this.onParent_SomeEvent
            }
        });
    },
    
    
    onParent_SomeEvent: function(component){
        if(component.mode == 'create'){
            var button = component.query('button#shouldRemoved');
            component.remove(button);
        }
    }

  2. #2
    Sencha - Support Team bjdurham85's Avatar
    Join Date
    Mar 2014
    Posts
    962
    Answers
    55

    Default

    Hi funckye,

    Having a little trouble understanding what you're trying to accomplish. Could you expand your example into a fiddle (http://fiddle.sencha.com) so I can help diagnose?

    Regards,
    Bryan

  3. #3

    Default

    this is my fiddle, hope it help

  4. #4
    Sencha - Support Team bjdurham85's Avatar
    Join Date
    Mar 2014
    Posts
    962
    Answers
    55

    Default

    Perhaps your fiddle needs a little more work? It is generating errors.


    Best!
    Bryan

  5. #5

    Default

    done, my fiddle work now.

  6. #6
    Sencha - Support Team bjdurham85's Avatar
    Join Date
    Mar 2014
    Posts
    962
    Answers
    55

    Default

    Thanks for the additional info. Perhaps instead of using action= instead try declaring an itemId and performing the "down" (section 7 in link below).

    https://www.sencha.com/blog/top-10-e...es-to-avoid-2/


    Additionally, while I'm not sure of your overall application design why not "hide/show" these buttons instead of removing/adding?


    Bryan

  7. #7

    Default

    query selector does no matter for me, it works within itemId or another component attributes,but the point is the parent component need to remove (or prevent to create) one or more children component, while the parent itself is initializing (could be render, afterrender, show, but no one i could use it to prevent).its for security purpose, so i thought removing is much suitable for my app.

Similar Threads

  1. Ext js override init component function
    By mirkotus in forum Ext: Q&A
    Replies: 2
    Last Post: 3 May 2014, 3:36 PM
  2. MVC change component's item's state before init?
    By wmcnamara in forum Ext: Q&A
    Replies: 3
    Last Post: 13 Feb 2013, 12:59 PM
  3. Access data of a parent component from a child component
    By vkryachko in forum Sencha Touch 2.x: Q&A
    Replies: 2
    Last Post: 25 Mar 2012, 10:07 AM
  4. how to override the init component
    By kclendinning in forum Sencha Ext JS Q&A
    Replies: 7
    Last Post: 19 Mar 2012, 12:34 PM
  5. accordion init component while collapsed
    By umit in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 29 Mar 2010, 1:16 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •