1. #11
    Ext JS Premium Member
    Join Date
    Mar 2008
    Location
    Santiago, Chile
    Posts
    10
    Vote Rating
    0
    josh256 is on a distinguished road

      0  

    Thumbs up Thanks Condor!

    Thanks Condor!


    Quote Originally Posted by Condor View Post
    1. Did you set Ext.BLANK_IMAGE_URL correctly?
    2. colIndex and rowIndex are numbers, not strings.
    1. You right, the set of Ext.BLANK_IMAGE_URL was wrong, I fix it and now works beautiful
    2. Yes, I was using the wrong data type.

    Thanks for your help again!

  2. #12
    Ext User brikonwall's Avatar
    Join Date
    Jan 2008
    Location
    Falls Chruch, VA, USA
    Posts
    23
    Vote Rating
    0
    brikonwall is on a distinguished road

      0  

    Default


    Condor, you rock...Thanks a lot for the help. Want some flowers?...just kidding...

  3. #13
    Sencha User
    Join Date
    Dec 2007
    Posts
    40
    Vote Rating
    0
    Seboss is on a distinguished road

      0  

    Default


    Does it seem realist to have a specific editor type for each individual cell of a column in an editor grid ? Or should I drop the idea altogether and resort to a good ol' form ?

    ex:
    PHP Code:
    [Col1Name] [Col2Value]
       
    Obj #1       [Combo]
       
    Obj #2       [Text]
    ... 

  4. #14
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    97
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    For a simple name/value grid there already is a Ext.grid.PropertyGrid.

  5. #15
    Sencha User
    Join Date
    Dec 2007
    Posts
    40
    Vote Rating
    0
    Seboss is on a distinguished road

      0  

    Default


    Thanks Condor.
    I'm having some difficulties using a Store as a datasource for a PropertyGrid.
    I'm not really sure how the source and store properties are supposed to work together.
    Time to go foraging for samples

  6. #16
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    97
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    PropertyGrid creates its own store (propertyGrid.propStore.store) that is filled with data from source (you can't specify your own store).

    You could use (untested):

    Code:
    var propertyGrid = new Ext.grid.PropertyGrid({
      ...
    });
    propertyGrid.propStore.store.proxy = new Ext.data.HttpProxy({
      url: 'myurl'
    });
    propertyGrid.propStore.store.relayEvents(propertyGrid.propStore.store.proxy, ["loadexception"]);
    propertyGrid.propStore.store.reader = new Ext.data.JsonReader({
      root: 'data',
      id: 'name'
    }, propertyGrid.propStore.store.recordType);
    propertyGrid.propStore.store.reader.onMetaChange = propertyGrid.propStore.store.onMetaChange.createDelegate(propertyGrid.propStore.store);
    propertyGrid.propStore.store.load();

  7. #17
    Ext User
    Join Date
    Dec 2007
    Posts
    31
    Vote Rating
    0
    Bionique is on a distinguished road

      0  

    Default


    @Condor: thanx for your example code (from 03-22-2008)! Works great!!!

  8. #18
    Ext User
    Join Date
    Jun 2007
    Posts
    16
    Vote Rating
    0
    Ben is on a distinguished road

      0  

    Default


    Excellent, extending your suggestion worked great for me, even where I had to use combo boxes in the cell with lists of values that vary by grid row!

    Thanks!

  9. #19
    Ext JS Premium Member
    Join Date
    Nov 2008
    Location
    Paris
    Posts
    52
    Vote Rating
    0
    tomcruz is on a distinguished road

      0  

    Default


    Excellent and very useful, thanks for that solution

    As a follow-up, does anyone have some leads regarding the same mechanism for renderers ?

    The problem is simple. If we override getCellEditor to return a textfield or a combo, we will need different rendering mechanisms depending on the editor used. A ComboBox will probably select its valueField's value while we want to display the displayField.

    This is of course solved with something like this :

    Code:
    var returnValue = value;
        var valueField = combo.valueField;
            
        // idx va contenir l'index de la valeur sélectionnée 
        // (inutilisé ici mais on peut s'en servir pour d'autres contrôles genre idx > 0)
        var idx = combo.store.findBy(function(record) 
        {
            if(record.get(valueField) == value) 
            {
                returnValue = record.get(combo.displayField);
                return true;
            }
        });
    where value is the combo's selected value, and combo the ComboBox object.

    Now the problem is we don't want that renderer to be called when the editor's input is not a combo. Or we would change the renderer to check for a valueField (for example) or an xtype to decide whether it has to go through the store, or just take the value and render it.

    getRenderer takes only the column as a parameter, so I guess I would have to change a lot to make it depend on the row like getCellEditor, and maybe it wouldn't get called in the right time.

    So should I go for a single "intelligent" renderer that examines the current input? Or is there a way to write several renderers that get called depending on the record "type" ?

  10. #20
    Sencha Premium Member
    Join Date
    Jul 2008
    Posts
    23
    Vote Rating
    0
    Joschy is on a distinguished road

      0  

    Default


    Thanks a lot for the good examples in this thread. Using it, works fine.

    For me, one question remains: Is there a way to copy the editors form one grid to another grid? The following example works, but just for one single edit action. After one edit action, the cell is not editable anymore.

    Code:
    getCellEditor: function(colIndex, rowIndex){ return new Ext.grid.GridEditor(grid_with_editors_to_copy.getColumnModel().getCellEditor(2)); }
    This scenario could be very helpful, if I copy a single grid record to another grid. So the editor could be copied, too. For example:

    col1, col2, col3, col4
    --------------------
    val1, val2, val3, val4
    val1, val2, val3, val4


    2nd Grid (includes one record)
    ---------
    col1:val1
    co2:val2
    col3:val3
    co4:val4

    Thanks a lot for any idea,
    Joschy