一个简的Ext.XTemplate例子

管省及城以树的款式出口

Ext.lib.Ajax.request(
       ‘POST’,
       ‘/Index/mainIndex’,
       { success: function (data) {
           data.responseText = “{pros:” + data.responseText + “}”;
//获取后台回调的省区都JSON格式数据
           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);
       }
       }
    );

图片 1

相关文章