1. #1
    Ext User
    Join Date
    Mar 2008
    Posts
    48
    Vote Rating
    0
    jeremy.hennegrave is on a distinguished road

      0  

    Default grid parent container on a form panel

    grid parent container on a form panel


    hi,

    I'm trying to get the parent container of a grid in a formpanel to markInvalid all the grid.

    This is not work :

    Code:
    var myGrid = new Ext.grid.EditorGridPanel({
            id: 'rightsGrid',
            store: gridStore,
            sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
            cm:colModel,
            width: 350,
            height:200,
            frame: true,
        });
    
    var myForm = new Ext.FormPanel({
            items: [myGrid],
        });
    
    // this is not working
    var elp = myGrid .findParentByType('x-form-item').getEl();
    //or
    var elp = myGrid .findParentByType('x-form-item');
    
    //this work
    //var elp = myGrid .getEl();
    How can i get the grid parent container ?


    regards,
    J

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,545
    Vote Rating
    64
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    Whan you say "not working", you mean it doesn't do what you expect. But you don't say what you expect.

    Read the docs for findParentByType. Then go to the top of that page to see available types.

    Any Component that is a child of a Container has http://dev.extjs.com/deploy/dev/docs...member=ownerCt (which is what the findParentByType function uses to go up the ownership chain)

  3. #3
    Ext User
    Join Date
    Mar 2008
    Posts
    48
    Vote Rating
    0
    jeremy.hennegrave is on a distinguished road

      0  

    Default


    here is what i want to do :

    Code:
    // not working 
    //var elp = profilGrid.getEl().findParent('x-form-item');
    
    //work 
    var elp = profilGrid.getEl();
    errorEl = elp.createChild({cls:'x-form-invalid-msg'});
    errorEl.setWidth(elp.getWidth(true)-20);
    errorEl.update('Invalid !');
    errorEl.show();
    The second line work but the errorEl is inside the grid so the invalid bottom line is below the message (see attachement). And i want to have the invalid bottom line above the errorMessage, it's why i want to get the container for calling the createchild method from him.

    Hope it's little bit clear.

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,545
    Vote Rating
    64
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    The reason that first line doesn't work is that a Grid is not wrapped inside a <div class="x-form-item">

    If you set the property/config isFormField:true, then it will be rendered as if it were a form Field, and get the wrapper.

  5. #5
    Ext User
    Join Date
    Mar 2008
    Posts
    48
    Vote Rating
    0
    jeremy.hennegrave is on a distinguished road

      0  

    Default


    it's nice for my shaped but the findParent() or findParentByType() doesn't work :

    [code]
    // see attachement
    var myGrid = new Ext.grid.EditorGridPanel({
    id: 'rightsGrid',
    store: gridStore,
    sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
    cm:colModel,
    width: 350,
    height:200,
    frame: true,
    isFormField:true,
    fieldLabel:'Profil associ
    Attached Images

  6. #6
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,545
    Vote Rating
    64
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    The Grid is not rendered immediately after you instantiate it.

  7. #7
    Ext User
    Join Date
    Mar 2008
    Posts
    48
    Vote Rating
    0
    jeremy.hennegrave is on a distinguished road

      0  

    Default


    yes sure, i've forget to precise that this code is only for example.

    My code is a little bit more complex.

    the grid is render and longer after the render i call a function that do the precedent code.

    And for more information i've the next code which is working (see attachement) :

    Code:
    var elp = myGrid.getEl();
    errorEl = elp.createChild({cls:'x-form-invalid-msg'});
    errorEl.setWidth(elp.getWidth(true)-20);
    errorEl.update('Ce champ est obligatoire !');
    errorEl.show();
    Like in the first post.


    regards,
    J
    Attached Images

  8. #8
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,545
    Vote Rating
    64
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    If the Grid is rendered in a layout:'form' Container, and has isFormField:true set, then it should get wrapped with a <div class="x-form-item">

    Check with Firebug to see if that's the case.

    You should be able to do grid.getEl().up('.x-form-item') to get that wrapper, and create the marker in it.

Thread Participants: 1