PDA

View Full Version : XTemplate and DataView (again)



oddy
7 Jul 2009, 1:39 AM
Good day.
What do I do wrong in the code below? I thought It's pretty straightforward, but... Something goes wrong.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css" />
<script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext/ext-all-debug.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
var store_news = new Ext.data.JsonStore({
remoteSort : true
, data : [{announce_title: "test", announce_author: "System administrator", announce_last_modified: "2009/07/03", id: 1, announce_body: "first test announce!"}, {announce_title: "test", announce_author: "System administrator", announce_last_modified: "2009/07/03", id: 2, announce_body: "first test announce!"}]
, fields : ["announce_author", "announce_title", "announce_body", "announce_last_modified"]
, autoLoad : true
});
var reader = {
xtype : "dataview"
, store : store_news
, tpl : new Ext.XTemplate(
"<tpl for='.'>"
, "<div class='news'>"
, "<h3>"
, "<span class='newsTitle'>{announce_title}</span>"
, "<span class='newsDate'>{announce_last_modified}</span>"
, "</h3>"
, "<div class='newsContent'>{announce_body}</div>"
, "<span class='newsAuthor'>{announce_author}</span>"
, "</div>"
, "</tpl>"
)
, itemSelector : "div.news"
};
new Ext.Panel({
renderTo : Ext.getBody()
, items : reader
, height : 200
});
});
</script>
</head>
<body><span></span></body>
</html>

Condor
7 Jul 2009, 1:45 AM
Your template is invalid (see here (http://extjs.com/forum/showthread.php?p=257738&highlight=XTemplate#post257738)).

oddy
7 Jul 2009, 2:03 AM
Your template is invalid (see here (http://extjs.com/forum/showthread.php?p=257738&highlight=XTemplate#post257738)).
You mean <tpl for='.'> is invalid? Then why this http://extjs.com/deploy/dev/examples/view/data-view.html works?

oddy
7 Jul 2009, 2:10 AM
Your template is invalid (see here (http://extjs.com/forum/showthread.php?p=257738&highlight=XTemplate#post257738)).
Jesus, you mean the quotes?! The type of a quotes does matter for XTemplate? This must be documented. And thank you, Condor. You save me a lot of time.