Results 1 to 6 of 6

Thread: Bug in updating field in Ext.form.FormPanel inside a Ext.window

  1. #1
    Ext User
    Join Date
    Mar 2008
    Location
    France
    Posts
    13

    Default Bug in updating field in Ext.form.FormPanel inside a Ext.window

    Hello dear Ext users,

    I've got more or less something like :
    Code:
    function editApplicationBtnHandler(){
    	if (selections.getCount() < 1) return;
    	// create the window on the first click and reuse on subsequent clicks
        if(!winAppEdit) {
    		var editApplicationForm = new Ext.form.FormPanel({
    	    	baseCls: 'x-plain',
    	    	labelWidth: 75,
    			bodyStyle:'padding:5px 5px 0',
    	        defaults: {width: 230},
    		    defaultType: 'textfield',
    		    items: [{
    					fieldLabel: 'Name',
    		            name: 'app_name',
    		            allowBlank:false,
                		anchor:'95%'
    				},{
    					fieldLabel: 'Path',
    					name: 'app_path',
    					allowBlank:false,
                		anchor:'95%'
    				},{
    					fieldLabel: 'Arguments',
    					name: 'app_args',
                		anchor:'95%'
    				},{
    					fieldLabel: 'Group',
    					name: 'app_group',
                		anchor:'95%'
    				}]
    		});
    	
            winAppEdit = new Ext.Window({
                el:'application-edit-win',
                layout:'fit',
                width:400,
                height:200,
                closeAction:'hide',
                plain:true,
    			modal:true,
                items: editApplicationForm,
                buttons: [
    				{text:'Save', handler:saveEditApplicationBtnHandler},
    				{text:'Cancel',handler: function(){ winAppEdit.hide(); } }
    			]
            });
        }
    	winAppEdit.items.items[0].items.items[0].value = selections.getSelected().get('name');
    	winAppEdit.items.items[0].items.items[1].value = selections.getSelected().get('path').replace(/\|/g, "\\").replace(/\?/g, " ");
    	winAppEdit.items.items[0].items.items[2].value = selections.getSelected().get('arguments').replace(/\|/g, "\\").replace(/\?/g, " ");
    	winAppEdit.items.items[0].items.items[3].value = selections.getSelected().get('group').replace(/\?/g, " ");
    	winAppEdit.doLayout();
    	winAppEdit.show(this);
    }
    I select a row in my grid, I click the Edit button, the fields in the new window are valued properly. I click cancel, it closes the window.
    Then appears my problem : I select another row in the grid, then click the Edit button, the win shows up and the fields values coming up are the older one.
    What should I add to have the values corresponding to new row selected ?

    I definitely must be missing something,
    Thanks.

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    try setValue() instead the value property

  3. #3

    Default

    Form fields must be rendered prior to setting their values (call the windows show method before setting values).
    A couple of hints:
    1) winAppEdit.items.items[0].items.items[0].value = selections.getSelected().get('name'); would better be done as: editApplicationForm.findField('app_name').setValue(selections.getSelected().get('name'))
    2) Since you are retreiving a record from a store (via the grid), you could simply call editApplicationForm.loadRecord(selections.getSelected()) if the form field names matched the record field names.

  4. #4
    Ext User
    Join Date
    Mar 2008
    Location
    France
    Posts
    13

    Thumbs up

    Quote Originally Posted by [email protected] View Post
    try setValue() instead the value property
    It worked perfectly !
    Thanks.

    Quote Originally Posted by devnull View Post
    Form fields must be rendered prior to setting their values (call the windows show method before setting values).
    A couple of hints:
    1) winAppEdit.items.items[0].items.items[0].value = selections.getSelected().get('name'); would better be done as: editApplicationForm.findField('app_name').setValue(selections.getSelected().get('name'))
    2) Since you are retreiving a record from a store (via the grid), you could simply call editApplicationForm.loadRecord(selections.getSelected()) if the form field names matched the record field names.
    The show() before changing value shows empty inputs.
    editApplicationForm wasn't not in the same scope, I moved it before the editApplicationBtnHandler() function.
    2-> Good solution, now the show() must be done before changing values.
    But if I use it I would loose my caracters replacement function.

    I finaly took your last solution, giving up the idea to use those replace().
    Thanks to both of you.

  5. #5
    Ext User
    Join Date
    Mar 2008
    Location
    France
    Posts
    13

    Default

    Oh I forgot to say one thing, the getForm() was missing.

    Code:
    editApplicationForm.findField('app_name').setValue (selections.getSelected().get('name'))
    editApplicationForm.loadRecord(selections.getSelec ted())
    The corrects calls are :

    Code:
    editApplicationForm.getForm().findField('app_name').setValue (selections.getSelected().get('name'))
    editApplicationForm.getForm().loadRecord(selections.getSelec ted())

  6. #6

    Default

    Ahh yes, thank you for correcting my correction

Posting Permissions

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