2011-03-17 48 views
0

這裏顯示我的數據從json的到來是我的js文件dashboard.js爲什麼沒有被網格

Ext.onReady(function(){ 
    Ext.QuickTips.init(); // **want to know why this is used** 

    // NOTE: This is an example showing simple state management. During development, 
    // it is generally best to disable state management as dynamically-generated ids 
    // can change across page loads, leading to unpredictable results. The developer 
    // should ensure that stable state ids are set for stateful components in real apps.  
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());**want to know why this is used** 


    // create the data store 
    var store = new Ext.data.JsonStore({ 
     // store configs 
     autoDestroy: true, 
     autoLoad :true, 
     url: 'api/index.php?_command=getresellers', 
     storeId: 'getresellers', 
     // reader configs 
     root: 'cityarray', 
     idProperty: 'cityname', 
     fields: ['cityname', 'totfollowup', 'totcallback', 'totnotintrested', 'totdealsclosed', 'totcallsreceived', 'totcallsentered', 'totresellerregistered', 
      'countiro', 'irotransferred', 'irodeferred' 
     ] 
    }); 


    // create the Grid 
    var grid = new Ext.grid.GridPanel({ 
     store: store, 
     columns: [ 
      { 
       id  :'cityname', 
       header : 'cityname', 
       width : 160, 
       sortable : true, 
       dataIndex: 'cityname' 
      } 
     ], 
     stripeRows: true, 
     autoExpandColumn: 'cityname', 
     height: 350, 
     width: 600, 
     title: 'Reseller Dashboard', 
     // config options for stateful behavior 
     stateful: true, 
     stateId: 'grid' 
    }); 

    // render the grid to the specified div in the page 
    grid.render('dashboard'); 
}); 

我的推杆一些意見,我想知道這是爲什麼使用.. 希望知道這是爲什麼使用 這裏是我的html文件

<html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>Reseller DashBoard</title> 

    <!-- ** CSS ** --> 
    <!-- base library --> 
    <link rel="stylesheet" type="text/css" href="css/ext-all.css" /> 

    <!-- overrides to base library --> 

    <!-- ** Javascript ** --> 
    <!-- ExtJS library: base/adapter --> 
    <script type="text/javascript" src="lib/ext-base-debug.js"></script> 

    <!-- ExtJS library: all widgets --> 
    <script type="text/javascript" src="lib/ext-all-debug.js"></script> 

    <!-- overrides to base library --> 

    <!-- page specific --> 
    <script type="text/javascript" src="lib/dashboard.js"></script> 

</head> 
<body> 

    <div id="dashboard"> 



    </div> 
</body> 
</html> 

這裏是我的JSON這我也渲染螢火..

{ 
    "countothercities": "0", 
    "directreseller": "14", 
    "totalresellersregisteredfor8cities": 33, 
    "cityarray": [{ 
     "cityname": "bangalore", 
     "totfollowup": "3", 
     "totcallback": "4", 
     "totnotintrested": "2", 
     "totdealsclosed": "0", 
     "totcallsreceived": "0", 
     "totcallsentered": "68", 
     "totresellerregistered": "6", 
     "countiro": "109", 
     "irotransferred": "83", 
     "irodeferred": "26" 
    }, { 

請檢查。

+0

我絕對缺少的一件事是store.load(),但ommision不負責不顯示網格。 – 2011-03-17 08:47:25

+0

我糾正了我改變了autoExpandColumn:'cityname',但現在我的網格正在渲染,但城市名稱的數據不會來? – XMen 2011-03-17 08:52:36

+0

哎呀!好了解決了問題是在JSON響應它包括一些HTML標籤 – XMen 2011-03-17 09:37:47

回答

0

Ext.QuickTips功能爲任何元素提供有吸引力和可定製的工具提示。詳情請看tutorial from Sencha learning site。 init方法被調用來初始化Ext.QuickTip的單例類。

Ext.state.Manager是全球的國家經理。要使用狀態管理器,您必須使用提供程序對其進行初始化。這是你正在做的與聲明:

Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); 

在這裏,您正在使用CookieProvider。通過使用這個,你要求ExtJS庫在cookies中存儲組件的狀態信息。

更新:getColumnWidth()方法發生錯誤。檢查您的列模型中是否有適當的width屬性值。要進行調試,請嘗試刪除所有列的寬度細節。我認爲你有更多的代碼沒有在這裏簡化。可能有一些錯字。

+0

但是,網格渲染怎麼樣,這是我的主要問題? – XMen 2011-03-17 07:41:18

+0

哦!我忽略了那個......你在哪裏得到這個錯誤?爲網格面板? – 2011-03-17 07:50:50

+0

在網格面板 – XMen 2011-03-17 08:25:00

0

試試這個:

//grid.render('dashboard'); //delete this line 
grid.renderTo = 'dashboard'; 
grid.show(); 

更新

嘗試刪除此行

autoExpandColumn: 'company' 
+0

這是行不通的 – XMen 2011-03-17 08:27:11

+0

看更新... – 2011-03-17 08:47:37

+0

已經完成之前,我糾正了我改變了autoExpandColumn:'cityname',但現在我的網格正在渲染,但城市名稱的數據不會來? – XMen 2011-03-17 08:51:04

0

這裏是你的錯誤:

autoExpandColumn: 'company', 

這個ID沒有列。

+0

我糾正了我改變了autoExpandColumn:'cityname',但現在我的網格正在渲染,但城市名稱的數據不會來? – XMen 2011-03-17 08:53:34