一個(gè)簡(jiǎn)單的Ext.XTemplate的實(shí)例代碼
更新時(shí)間:2012年03月18日 14:38:23 作者:
把省份與城市以樹的形式輸出的Ext.XTemplate的實(shí)例代碼,需要的朋友可以參考下
把省份與城市以樹的形式輸出
Ext.lib.Ajax.request(
'POST',
'/Index/mainIndex',
{ success: function (data) {
data.responseText = "{pros:" + data.responseText + "}"; //獲取后臺(tái)回調(diào)的省份城市JSON格式數(shù)據(jù)
var response = Ext.util.JSON.decode(data.responseText);
var province = new Ext.XTemplate(
'<tpl for="pros">',//遍歷讀取pros
'<p>{id}--{text}</p>',
'<tpl for="children">',//遍歷讀取pros下的children
'<p style="margin-left:10px;">{id}--{text}</p>',
'</tpl>',
'</tpl>'
);
province.compile();
province.append("Div2", response);
}
}
);
復(fù)制代碼 代碼如下:
Ext.lib.Ajax.request(
'POST',
'/Index/mainIndex',
{ success: function (data) {
data.responseText = "{pros:" + data.responseText + "}"; //獲取后臺(tái)回調(diào)的省份城市JSON格式數(shù)據(jù)
var response = Ext.util.JSON.decode(data.responseText);
var province = new Ext.XTemplate(
'<tpl for="pros">',//遍歷讀取pros
'<p>{id}--{text}</p>',
'<tpl for="children">',//遍歷讀取pros下的children
'<p style="margin-left:10px;">{id}--{text}</p>',
'</tpl>',
'</tpl>'
);
province.compile();
province.append("Div2", response);
}
}
);

相關(guān)文章
extjs4 treepanel動(dòng)態(tài)改變行高度示例
本文為大家介紹下extjs4 treepanel如何動(dòng)態(tài)改變行高度,下面有個(gè)不錯(cuò)的示例,感興趣的朋友可以參考下2013-12-12
ExtJS 2.0實(shí)用簡(jiǎn)明教程 之獲得ExtJS
要使用ExtJS,那么首先要得到ExtJS庫文件,該框架是一個(gè)開源的,可以直接從官方網(wǎng)站下載2009-04-04
Extjs中RowExpander控件的默認(rèn)展開問題示例探討
本文為大家探討下關(guān)于Extjs中RowExpander控件的默認(rèn)展開問題,下面有個(gè)不錯(cuò)的示例,感興趣的朋友可以參考下2014-01-01
Extjs的FileUploadField文件上傳出現(xiàn)了兩個(gè)上傳按鈕
Extjs的FileUploadField文件上傳在頁面中出現(xiàn)了兩個(gè)上傳按鈕,這個(gè)是和ext的本身css的樣式有關(guān)系,所以要將樣式修改下2014-04-04

