2010-04-03 88 views
1

我對ExtJS相當陌生。我採用了一些示例,並添加了通過單擊某個鏈接將選項卡添加到選項卡控件的功能。到現在爲止還挺好。現在我想將一個ExtJS表加載到新選項卡上。項目(行,列)在服務器端的數據庫中定義。你能給我一些提示如何在創建標籤時自動添加表格嗎?在動態添加的選項卡中添加表格

回答

2

自動加載適合從服務器端代碼拉取HTML表格。這些數據是否得到更新?如果是這樣,您將需要重新加載整個HTML。我建議使用一個網格,而不是:

// tabPanel definitinon 
    { 
     xtype:"grid", 
     //tabId is a unique value created at the time of the tab 
     id:"general_props_status_grid_" + tabId, 
     ds: C.createStore({ 
      storeId:"general_props_status_grid_" + tabId, 
      autoLoad:true 
      proxy: new Ext.data.HttpProxy({ 
       //path to a serverside page that gerenates a JSON table contents 
       url: '?fuseaction=qry_statuses' 
      }), 

      reader: new Ext.data.JsonReader({ 
       id: 'status_id', 
       root:'data' 
      }, [ 
       {name: 'status_id'}, 
       {name: 'name'} 
      ]), 
      remoteSort: false 
     }), 
     columns:[{ 
      header: "Status ID", 
      dataIndex: 'status_id', 
      width:20, 
      hidden:true, 
      sortable:true 
     },{ 
      header: "Name", 
      dataIndex: 'name', 
      hideable:false, 
      renderer:function(val){ 
       return "<span class='link'>" + val +"</span>" 
      }, 
      width:150, 
      sortable:true 
     }], 
     sm: new Ext.grid.RowSelectionModel({singleSelect:true}), 
     loadMask: true, 
     listeners: { 
      activate:function(thisGrid){ 
       //this will reload the grid each time this tab is selected 
       thisGrid.getStore().reload(); 
      } 
     } 
    } 

有一噸的供電網的選項,但上面的例子顯示了通過回調自動更新的網格。

0

好的,我做了一些進一步的閱讀我的事情,這個autoLoad屬性在這裏幫了我很多。 我會從這裏出發。