2015-06-01 36 views
1

我有一個gridpanel有兩列,第一列顯示用戶名,第二列是一個帶編輯按鈕的動作列,當點擊編輯按鈕時,通過顯示一個帶窗體的窗口並輸入新密碼來更改用戶密碼。extjs通過param形式

如何將「用戶名」傳遞給窗體並顯示。 我正在嘗試使用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 
    } 

回答

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' 
        } 
       }] 
      }] 
     }); 
    } 
});