最近我一直在使用Dojo的编程应用接口开始,是新来的Dojo和我的第一项任务是创建一个具有行显示数据库和文件图标文件列表中的自定义表部件。该小部件将类似于数据网格,但我们希望使用类似于列表的表格,因为数据网格有时可能会对网络造成很大影响。谢谢你的帮助将非常感激。如何在dojo中创建自定义表部件?
0
A
回答
0
好吧,假设你实例化自定义窗口小部件与数据存储,一样的网格。您的商店,这取决于哪种类型(例如:itemfilereadstore)有一个邮件列表和下面将对其进行处理,同时创建行到你的widget
<script>
dojo.declare("myTable", [dijit._Templated], {
// define which template to instantiate on your domNode (in this case, table becomes the domNode of your widget)
templateString: '<table><thead dojo-attach-point="headNode"></thead><tbody dojo-attach-point="bodyNode"></tbody></table>',
constructor: function(args) {
args = args || {};
if(!args.store) console.warn("No store supplied");
this.store = args.store
// Note; there are a number of methods to achieve this hook,
// depending on which type of datastore is in use
this.store.fetch({ onComplete: dojo.hitch(this, "_onload") });
},
// function to be called whenever the store has fetched an item set
_onload: function(items) {
var _t = this, store = _t.store, head = _t.headNode, body = _t.bodyNode;
var headIsFilled = false;
// 'haxed' reset of current setup, simply resetting innerhtml
_t.rowIdentifiers = [];
_t.rows = [];
head.innerHTML = "<tr></tr>";
head = head.firstChild;
body.innerHTML = "";
dojo.forEach(items, function(item) {
// generic way of simply showing all of contents available in store
// prefereably, set this structure in an argument while constructing and
// fill head with, say _t.layout
if(!headIsFilled) {
// loops the first item, making sure not to take in any internal references, should check for item
for(var i in item) if(item.hasOwnProperty(i) && i != "_S" && i != "_RI") {
dojo.place("<th>"+i+"</th>");
_t.rowIdentifiers.push(i);
}
headIsFilled = true; // only once
}
var tr = dojo.create("tr", null, body);
var row = { el : tr }
var cell;
dojo.forEach(_t.rowIdentifiers, function(key) {
cell = dojo.create("td", {innerHTML : store.getValue(item, key)}, tr);
row[key] = cell.innerHTML; // the toString value of item
});
_t.rows.push(row);
});
}
});
</script>
代码尚未评估,但应给予的总体思路如何启动一个小部件。
注意在代码中有两件事情; templateString
是基本的HTML布局应该是什么,有一些“神奇”约定,在本例中仅attachpoints用于有_Templated混入使得其domNodes在窗口小部件引用
见下面为首发教程和一般参考:
http://dojotoolkit.org/documentation/tutorials/1.6/understanding_widget/
http://dojotoolkit.org/documentation/tutorials/1.6/templated/
相关问题
- 1. 创建自定义Dojo小部件
- 2. 在dojo中创建自定义StackController
- 3. 无法为特定属性创建Dojo自定义小部件
- 4. 如何在以声明方式创建后检索自定义Dojo小部件
- 5. 如何从SharePoint 2007中的自定义列表创建自定义Web部件
- 6. 如何在C中的GTK3中创建自定义小部件?
- 7. 在自定义小部件中添加dojo小部件
- 8. 如何在自定义ProgressBar小部件中创建TextSwitcher
- 9. dojo自定义小部件不工作
- 10. 如何在自定义AMD的Dojo小部件
- 11. 在Dojo中创建小部件
- 12. 建立自定义dojo
- 13. 如何在TFS构建报告中创建自定义部分?
- 14. 为Android创建自定义小部件
- 15. 创建自定义类别小部件
- 16. 创建自定义小部件
- 17. 如何创建自定义表单
- 18. 如何创建Web部件中自定义列表中插入数据
- 19. 如何在自定义控件中创建名为valuechanged的自定义事件
- 20. Dojo,如何摧毁一个自定义小部件?
- 21. 如何在自定义类中创建自定义IBActions?
- 22. 如何在Dojo小部件模板中创建唯一ID?
- 23. 自定义Dojo RichTextEditor插件
- 24. 如何创建自定义)
- 25. 在Joomla中创建自定义表单
- 26. 在WPF中创建自定义表单?
- 27. 如何在我的app.config中创建自定义部分?
- 28. 如何创建自定义Swing组件
- 29. 我如何创建自定义控件?
- 30. 如何创建自定义GUI组件?
感谢你的帮助,但该数据应被传递到通过JSON数据格式,每行的第一列的表中的行应该是一个复选框和第二列我字符串和第三列文件的图像图标。 – Ousman
现在,这就是为什么有一个与comperators和格渲染/格式功能的网格组件..我不知道为什么包装JSON数据到存储是一个问题但是,它很容易足以让你自己'xhr.load(响应){对于eval(响应)中的每个项目构造tr'函数。给出一个你的JSON看起来像什么的示例,以及如何使用html代码片段显示它,并且答案将会出现 – mschr