extjs传递param形成

时间:2015-06-01 20:42:19

标签: forms extjs

我有一个带有两列的gridpanel,第一列显示用户名,第二列是带编辑按钮的actioncolumn,当​​点击编辑按钮时,通过显示带窗体的窗口更改用户密码并输入新密码。

如何传递"用户名"形式和表现。 我试图使用Store。 还有其他办法吗?

我的代码

gridpanelview.js
actioncolumn:
/*...config*/
{
    xtype: 'actioncolumn',
    items: [
        {
         handler:function(view, rowIndex, colIndex, item, e, record, row) {
                        var pwdwin = Ext.create('myapp.view.SetPwdWin');
                        var store = Ext.create(myapp.store.mystore)
                         mysore.setData(record)
                        pwdwin.show();
                    },
                    icon: 'edit.png',
                    tooltip: 'change passpword'
    }]
}



 mywindow.js:
        /*...config*/
        dockedItems: [
            {
                xtype: 'form',
                dock: 'top',
                reference: 'form',
                height: 200,
                id: 'pwd_form',
                bodyPadding: 10,
                header: false,
                title: 'My Form',
                layout: {
                    type: 'vbox',
                    align: 'center'
                },
                items: [
                    {
                        xtype: 'textfield',
                        flex: 1,
                        id: 'user_name',
                        maxHeight: 20,
                        padding: 10,
                        fieldLabel: 'Name',
                        editable: false
                    },
                    {
                        xtype: 'textfield',
                        id: 'new_pwd',
                        padding: 10,
                        fieldLabel: 'Password',
                        inputId: 'new_pwd_value',
                        inputType: 'password',
                        allowBlank: false,
                        maxLength: 20,
                        minLength: 6
                    },
                    {
                        xtype: 'textfield',
                        id: 'confirm_pwd',
                        fieldLabel: 'confirm',
                        inputId: 'confirm_pwd_value',
                        inputType: 'password',
                        allowBlank: false,
                        maxLength: 20,
                        minLength: 6
                    },
                    {
                        xtype: 'button',
                        text: 'OK',
                        listeners: {
                            click: 'set_new_pwd'
                        }
                    }
                ]
            }
        ],
set_form_username: function() {
        //get Store data 
        form = this.getReferences().form.getForm();
       //how to set username to the label
}
     set_new_pwd: function(button, e, eOpts) {
    //send username and new username to server
    }

1 个答案:

答案 0 :(得分:0)

尝试使用getDockingRefItems('pwd_form')getDockedItems()

例如:

Ext.application({
    name: 'Fiddle',

    launch: function() {

        Ext.create('Ext.Button', {
            text: 'Click me',
            renderTo: Ext.getBody(),
            handler: function() {
                // way 1
                w.getDockedItems()[0].items.items[0].setValue('your user name');

                // way2
                w.getDockingRefItems('pwd_form')[1].setValue('your user name');
                w.show();

            }
        });

        var w = Ext.create('Ext.window.Window', {
            title: 'Hello',
            height: 200,
            width: 400,
            dockedItems: [{
                xtype: 'form',
                dock: 'top',
                reference: 'form',
                height: 200,
                id: 'pwd_form',
                bodyPadding: 10,
                header: false,
                title: 'My Form',
                layout: {
                    type: 'vbox',
                    align: 'center'
                },
                items: [{
                    xtype: 'textfield',
                    flex: 1,
                    id: 'user_name',
                    maxHeight: 20,
                    padding: 10,
                    fieldLabel: 'Name',
                    editable: false
                }, {
                    xtype: 'textfield',
                    id: 'new_pwd',
                    padding: 10,
                    fieldLabel: 'Password',
                    inputId: 'new_pwd_value',
                    inputType: 'password',
                    allowBlank: false,
                    maxLength: 20,
                    minLength: 6
                }, {
                    xtype: 'textfield',
                    id: 'confirm_pwd',
                    fieldLabel: 'confirm',
                    inputId: 'confirm_pwd_value',
                    inputType: 'password',
                    allowBlank: false,
                    maxLength: 20,
                    minLength: 6
                }, {
                    xtype: 'button',
                    text: 'OK',
                    listeners: {
                        click: 'set_new_pwd'
                    }
                }]
            }]
        });
    }
});