Results 1 to 9 of 9

Thread: Change cell value in EditorGridPanel

  1. #1
    Ext JS Premium Member
    Join Date
    Mar 2008
    Location
    Moscow
    Posts
    137

    Default Change cell value in EditorGridPanel

    For my fields I use TriggerField. Trigger function shows window with simple grid with dictionary data, where user might choose value to set into EditorGridPanel. For now I do it like this :

    Code:
    editor:new Ext.form.DictField({onTriggerClick:function() { ShowDictionary(MyGrid, this); }})
    Code:
    function ShowDictionary(MyGrid, MyField){
       var oSM = MyGrid.getSelectionModel();
       MyGrid.startEditing(oSM.getSelectedCell()[0],oSM.getSelectedCell()[1]);
    
       Some-Window-Show();
    
       MyField.setValue(Some-Window-Result);
    
       MyGrid.stopEditing(false);
    }
    The value is set, when I try to debug this with firebug, but in EditorGridPanel it's not shown... EditorGrid shows the original value... Can anyone help? How can I modify any cell in Grid in right way...

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    If you are programatically changing an EditorGridPanel's value, then return false to this event: http://dev.extjs.com/deploy/dev/docs...r=validateedit

  3. #3
    Ext JS Premium Member
    Join Date
    Mar 2008
    Location
    Moscow
    Posts
    137

    Default

    Quote Originally Posted by Animal View Post
    If you are programatically changing an EditorGridPanel's value, then return false to this event: http://dev.extjs.com/deploy/dev/docs...r=validateedit
    This events dosn't fire after I made setValue to the field ;(

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    It fires when the editing is finished

  5. #5
    Ext JS Premium Member
    Join Date
    Mar 2008
    Location
    Moscow
    Posts
    137

    Default

    Quote Originally Posted by Animal View Post
    It fires when the editing is finished
    to see, what happens Iextend Ext.grid.EditorGridPanel like this:

    Code:
    Ext.rostu.EditorGridPanel = function(config){
      Ext.rostu.EditorGridPanel.superclass.constructor.call(this, config);
    };
    
    Ext.extend(Ext.rostu.EditorGridPanel, Ext.grid.EditorGridPanel,  {
      clicksToEdit:1,
    
      initEvents : function(){
        Ext.rostu.EditorGridPanel.superclass.initEvents.call(this);
            
        this.on("validateedit", this.onValidateEdit, this, [true]);
      },
    
      onValidateEdit: function(e){
        alert("Validating the field...");
    
        console.dir(e);
      }
    });
    When I edit any field with text or number (editor:new Ext.form.NumberField) - it fires. When i edit my field - it doesn't fire. My field extended from Trigger field, here is the code :
    Code:
    Ext.form.DictField = Ext.extend(Ext.form.TriggerField,  {
       dict_id : 0,
       dict_caption : "",   
    
       initComponent : function(){
         Ext.form.DictField.superclass.initComponent.call(this);
    
         if(!this.hiddenName){
             this.hiddenName = this.name+"_id";
         };
       },
    
       onShowDict: function(){
         
       },
    
       onRender : function(ct, position){
            Ext.form.ComboBox.superclass.onRender.call(this, ct, position);
    
            if(this.hiddenName){
                this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName, id: (this.hiddenId||this.hiddenName)},
                        'before', true);
            };
        }
    });
    
    Ext.reg('dictfield', Ext.form.DictField);

  6. #6
    Ext JS Premium Member
    Join Date
    Mar 2008
    Location
    Moscow
    Posts
    137

    Default

    Can someone help, please? What am I doing wrong? Found this theme : http://extjs.com/forum/showthread.php?t=3613

    There was the same problem. It works in form, but doesn't work in editable grid panel (

  7. #7
    Ext User
    Join Date
    Jun 2008
    Location
    Heidelberg, Germany
    Posts
    10

    Default

    Chemist,
    I had the same problem and found that overwriting validateBlur of TriggerField does the trick (actually found that in the DateField implementation).

    Here's a sample of a TriggerField that uses a prompt to ask for a value:

    Code:
    var CustomTriggerField = Ext.extend(Ext.form.TriggerField, {
        constructor: function(config) {
            CustomTriggerField.superclass.constructor.call(this,config);
        },
        onTriggerClick: function(e) {
            this.prompting=true;
            Ext.Msg.prompt('Rule entry', 'Please enter the rule:', function(btn, text){
                if (btn == 'ok'){
                    this.setValue(text);
                    this.prompting=false;
                }
            },this,false,this.getValue());
        },
        validateBlur : function(){
            return !this.prompting;
        }    
    })
    Good luck!
    Gnomie

  8. #8
    Ext User
    Join Date
    Sep 2008
    Location
    colombia
    Posts
    13

    Default

    it works,but is there any way to prevent this


    the field stay on the top of the popup,
    I just used the validateBlur function,and this happened


    Code:
    SM.Edicion=Ext.extend(Ext.form.TriggerField,{
        initComponent : function(){
            SM.Edicion.superclass.initComponent.call(this);
            this.onTriggerClick=function(){
                if(!this.disabled)this.editar(this);
            }
        },
        setValue: function(text) {
            SM.Edicion.superclass.setValue.call(this, text);
        },
       validateBlur : function(){
            return !this.editW || !this.editW.isVisible();
        },
        editar:function(field){
            var editWindow=new Ext.Window({
                heigth:200,
                width:300,
                modal:true,
                items:[{
                    xtype:'textarea',
                    height:200,
                    width:300,
                    value:field.getValue()
                }],
                bbar:new Ext.StatusBar({
                    statusAlign: 'right',
                    items:[
                    {
                        icon:'images/accept.png',
                        cls:"x-btn-icon",
                        tooltip: {
                            text:'Aceptar'
                        },
                        handler:function(){
                            //field.prompting=true;
                            field.setValue(editWindow.items.items[0].getValue());
                            console.log(field.getValue());
                            editWindow.close();
                            //field.prompting=false;
                        }
                    }]
                })
            });
            field.editW=editWindow;
            editWindow.show();
            editWindow.items.items[0].focus(false,50);
        },
        triggerClass : "x-form-browse-trigger"
    });

  9. #9
    Ext User
    Join Date
    Jun 2008
    Location
    Heidelberg, Germany
    Posts
    10

    Default

    Good morning israeldehoz,

    never ran into that problem again since I found that fix and the code is used a lot. Can you post a clean room example (e.g. one HTML file) that reproduces the problem you describe? Is that happening in any browser? Are you using ExtJS 2.x or newer?

    Thanks,
    Henning

Posting Permissions

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