2014-05-04 27 views
0

這是我的彈出式選項卡。 我需要在商店的標籤2中給記錄提供一個值給gridpanel,以通過category_id從服務器端獲取屬性。在官方文檔中搜索答案並沒有找到。 可以幫助我嗎?EXT JS - 點擊轉移記錄存儲彈出網格面板

Ext.define('desk.view.CategoryPopup', { 
    extend: 'Ext.window.Window', 
    alias: 'widget.categorypopup', 

    title: 'Change Category', 
    layout: 'fit', 
    autoShow: true, 
    bdoyPadding: 10, 

    initComponent: function(){ 
     this.items = [{ 
      xtype: 'tabpanel', 
      items: [ 
       { 
        xtype: 'form', 
        title: 'Add/Edit/Delete Category', 
        items: [ 
         { 
          xtype: 'textfield', 
          name: 'name', 
          fieldLabel: 'Parent Category' 
         }, 
         { 
          xtype: 'textfield', 
          name: 'new', 
          fieldLabel: 'New Category' 
         }, 
         { 
          xtype: 'textfield', 
          name: 'id', 
          fieldLabel: 'Category ID', 
          hidden: true 
         }, 
         { 
          xtype: 'textfield', 
          name: 'parent', 
          fieldLabel: 'Parent ID', 
          hidden: true 
         } 
        ], 
        bodyPadding: 10 
       }, 
       { 
        xtype: 'gridpanel', 
        alias: 'widget.categoryattr', 
        title: 'Attributes', 
        height: 350, 
        buttons: [{'text': 'Add attribute', 'action' : 'add-attribute'}], 
        columns: [ 
         { 
          name: 'Name', 
          dataIndex: 'name' 
         } 
        ], 
        width: 300, 
        store: Ext.widget('categoryattributes') 
       } 
      ] 
     }]; 

     this.buttons = [ 
      { 
       text: 'Update', 
       action: 'add' 
      }, 
      { 
       text: 'Delete', 
       action: 'delete' 
      } 
     ]; 

     this.callParent(arguments); 
    } 
}) 

This is function in controller 

editCategories: function(grid, record){ 
     var view = Ext.widget('categorypopup'); 
     view.down('form').loadRecord(record); 
    } 
+0

所以你想要將表單的記錄添加到按鈕按下的網格商店? –

+0

沒有。我有一個類別的網格,我想通過category_id在彈出窗口 –

+0

從數據庫中獲取屬性,你可以請更具體:你的意思是類別的屬性,你是否需要填補從商店數據庫...? –

回答

0

你需要的東西是這樣的:

editCategories: function(grid, record){ 
    var view = Ext.widget('categorypopup'); 
    view.down('form').loadRecord(record); 
    Ext.Ajax.request({ 
     url: '/api/category/'+ record.getId() +'/attributes', //example url insert your webservice 
     success: function(response){ 
      var attributes = Ext.decode(response.responseText); 
      view.down('grid').getStore().loadData(attributes); 
     } 
    }); 
} 

你需要一個商店,爲您的網格模型。

+0

謝謝,我會嘗試 –

+0

謝謝,它的工作原理 –