2013-03-26 72 views
3

加載數據我想用ExtJS的插件「RowExpander」,但是,我會加載數據時,該事件expandbody被激發。 我已經嘗試此代碼,但我不知道如何設置rwoBody的擴展內容:ExtJS的4.2.0 RowExpander動態

this.GridPrincipal.getView().addListener('expandbody', function (rowNode, record, expandRow, eOpts) { 


     Ext.Ajax.request({ 
      url: 'getData/' + record.get('id'), 
      method: 'POST', 
      success: function (result, request) { 
      // retrive the data 
      var jsonData = Ext.util.JSON.decode(result.responseText); 
      //code to change the text of the RowBody 
          //.... 
      }, 
      failure: function (result, request) { 
      Ext.MessageBox.alert('Failed', result.responseText); 
      return false; 
      } 
      }); 



    }); 

非常感謝你。

回答

1

我有同樣的問題。我的解決方案是:

Ext.get(expandRow).setHTML('New Text'); 

我會很樂意聽到有沒有更好的方法。

3

一個解決方案,使用它可以提供任何數據,甚至其他組件進入擴張是給它分配股利。

plugins: [{ 
     ptype: 'rowexpander', 
     rowBodyTpl: ['<div id="ux-row-expander-box-{id}"></div>'], 
     expandOnRender: true, 
     expandOnDblClick: true 
    }] 

其中'id'是商店的id字段。

上expandbody事件未來

,您可以使用例如獲取數據Ajax請求,然後使用renderTo配置將包含數據的面板或網格等渲染到此div中。