我在 extjs4 工作。我有服务器提供的 json 数据 -
{"words":{"word":"flower","wordMeanings":[{"wordType":"n","meaning":"flower1"},{"wordType":"n","meaning":"flower2"},{"wordType":"n","meaning":"flower3"},{"wordType":"n","meaning":"flower4"}],"wordMedias":[{"mediaPath":"flower.jpg"}],"wordPronunciations":[{"pronunciation":"flowerpronoun"}]}}
为了显示这个json,我创建了视图——
Ext.define('Balaee.view.kp.Word.Dictionary', {
extend:'Ext.view.View',
alias:'widget.Dictionary',
id:'DictionaryId',
autoShow: true,
store:'kp.WordStore',
config:
{ html:'Word Details',
tpl:'<tpl for=".">'+
'<div id="main">'+
'</br>'+
'<table border=0 cellspacing=35>'+
'<tr><td><b> Word:-</b><b>{word}</b></td></tr></br>'+
//'<b><tr><td><b>Word Type</b></td><td><b>Meaning</b></td></tr>'+
//'<var i=>'+
'<tpl for="wordMeanings">'+
//'<tr><td>{wordType}={meaning}</td></tr>'+
'<tr><td>*{meaning}</td>'+
'</tpl>'+
'<tpl for="wordMedias">'+
//'<tr><td>{mediaPath}</td></tr>'+
'<td>Image:'+
'<input type=image src='+
'http://images.balaee.com/images/'+
'{mediaPath} :'+
'</td>'+
'</tpl>'+
'<tpl for="wordPronunciations">'+
'<tr><td>pronunciation:'+
'{pronunciation}'+
'</td></tr>'+
'</tpl>'+
'</div>'+
'</tpl>',
itemSelector:'div.main' }});
它的工作和正确显示所有字段。但我想以正确的格式显示这些信息。意味着一个块中的所有名词,一个块中的所有图像。那么如何在 extjs4 中为这些 tpl 视图进行格式化