2
是否有比可以连接到Dojo商店的DataGrid更简单的列表类型?dojo的简单商店连接列表
我想要商店的数据抽象,但我不需要头和单元结构。我希望在数据库的表示方面更加灵活,在这里可能每行都会调用一个函数来进行布局...
是否有比可以连接到Dojo商店的DataGrid更简单的列表类型?dojo的简单商店连接列表
我想要商店的数据抽象,但我不需要头和单元结构。我希望在数据库的表示方面更加灵活,在这里可能每行都会调用一个函数来进行布局...
你问一个非常好的问题。我实际上有一篇博客文章仍然处于草稿形式,名为“DataGrid不应该是您的第一个选项”。
我已经做了一些事情,使用商店以重复的形式显示商店的数据。
我已经手动构建一个html表使用dom构造和每个。
var table = dojo.create('table', {}, parentNode);
var tbody = dojo.create('tbody', {}, table); // a version of IE needs this or it won't render the table
store.fetch({ // this is a dojo.data.ItemFileReadStore, but you cana dapt to the dojo.Store API
query: {},
onComplete: function(itms) {
dojo.forEach(itms, function(itm, idx) {
var tr = dojo.create('tr', {}, tbody);
// use idx to set odd/even css class
// create tds and the data that goes in them
});
}
});
我也创建了一个中继器,其中我有一个字符串形式的html模板,并使用它来实例化每行的html。
var htmlTemplate = '<div>${name}</div>'; // assumes name is in the data item
store.fetch({ // this is a dojo.data.ItemFileReadStore, but you cana dapt to the dojo.Store API
query: {},
onComplete: function(itms) {
dojo.forEach(itms, function(itm, idx) {
var expandedHtml = dojo.replace(htmlTemplate, itm);
// use dojo.place to put the html where you want it
});
}
});
您还可以为每个项目实例化一个小部件。
我有一个不同的博客帖子的一部分,这也证明了这一点。在底部,有一个fnDisplayOrders函数可以完成上述的一些操作。 https://gist.github.com/2010137 – 2012-04-07 15:55:23
是的,我想我需要诉诸这样的解决方案。尽管如此,我认为dojo拥有所有这些抽象商店,然后缺少小部件来使用它们,这有点奇怪。 – RickyA 2012-04-07 20:47:43