2013-05-02 62 views
1

我正在extjs4 + yii框架中工作。我的服務器端在yii [php],客戶端在extjs4。我從服務器端以json格式發送數據。 我有JSON原樣如何在extjs4中使用tpl顯示嵌套的json

{ 
    "data": { 
     "Meaning": [ 
      { 
       "Noun": "sea" 
      }, 
      { 
       "Adverb": "Null" 
      }, 
      { 
       "Adjective": "Null" 
      } 
     ], 
     "pronunciation": "sea", 
     "Media": [ 
      { 
       "image": "abc.jpg" 
      }, 
      { 
       "image": "xyz.jpg" 
      }, 
      { 
       "Video": "Windows Media Audio/Video file (.wmv)" 
      } 
     ] 
    } 
} 

我想顯示在視圖中使用TPL的ExtJS的這個JSON。那麼如何使用extjs tpl顯示這個嵌套的json呢?

+0

看一看這裏: http://stackoverflow.com/questions/15253118/extjs-parsing-nested-json-in-template – PHP 2013-05-03 11:14:56

回答

0

簡單的解決方案:

Ext.widget('panel', { 
    renderTo: Ext.getBody() 
    // 4 is the number of indentation spaces 
    ,tpl: '<pre>{[JSON.stringify(values, null, 4)]}</pre>' 
    ,height: 400 
    ,data: ... // sample data 
});