将表添加到我的dojo代码中
Add table to my dojo code
我有一个dojo对话框函数,希望能够添加一个有5行的表。我该怎么做?下面是我的代码。
dojo.require("dijit.Dialog");
dojo.require("dijit.form.TextBox");
dojo.require("dojox.grid.EnhancedGrid");
dojo.addOnLoad(function() {
popup = new dijit.Dialog({
title: "Non-Spatial Permanent Feature Deductions...",
style: "width: 750px; height: 400px",
content: "<input dojoType='dijit.form.Button' type='button' name='name' id='name' label='OK'>"
});
popup.show()
});
如果你的表行是固定的,即5行,那么你可以做一件简单的事情,创建一个html文件,它有5行的表,并在对话框中调用该文件。
popup = new dijit.Dialog({
title: "Non-Spatial Permanent Feature Deductions...",
style: "width: 750px; height: 400px",
href:"table.html"
});
当我需要一个包含大量dijit或自定义功能的对话框时,我最终会制作一个自定义对话框dijit。这是我当前项目中的一个。
define([
"dojo/_base/declare",
"dijit/_Widget",
"dijit/_TemplatedMixin",
"dijit/_WidgetsInTemplateMixin",
"dojo/i18n!magic/nls/common",
"dojo/text!./templates/emrSelection.html",
"dojo/dom-construct",
"dojo/on",
"dojo/Evented",
"dojo/_base/connect",
"dojo/query",
"dojo/_base/lang",
"dijit/Dialog",
"dijit/form/CheckBox"
],
function (declare, _Widget, _TemplatedMixin, _WidgetsInTemplateMixin, i18n, template, domConstruct, on, Evented, connect, query, lang, Dialog, CheckBox) {
return declare("project.customDialog", [Dialog], {
title: i18n.customDialog.title,
emrIds: [],
constructor: function(/*Object*/ kwArgs) {
lang.mixin(this, kwArgs);
var contentWidget = new (declare([_Widget, _TemplatedMixin, _WidgetsInTemplateMixin], {
closeLabel: i18n.close,
templateString: template,
baseClass: "customDialog"
}));
contentWidget.startup();
this.content = contentWidget;
},
postCreate: function() {
this.inherited(arguments);
},
startup: function() {
this.inherited(arguments);
this._createTable();
},
_createTable : function() {
var that = this;
var i = 0;
var tr = null;
this.store.query().forEach(lang.hitch(this, function(emr){
var state = that.emrIds.indexOf(emr.id) != -1;
if(i++%3 == 0) {
tr = domConstruct.create("tr");
domConstruct.place(tr, that.content.tableBody);
}
var td1c = domConstruct.create("td", {'class':"checkBox"}, tr);
var td1l = domConstruct.create("td", {'class':"label"}, tr);
var box = that._createCheckBox(emr.name, state, emr.id);
domConstruct.place(box.domNode, td1c);
domConstruct.place("<label for='checkbox'>"+emr.name+"</label>", td1l);
}));
},
_createCheckBox : function(name, checked, id) {
var box = CheckBox({
name: name,
value: name,
checked: checked,
emr_id: id,
onChange: lang.hitch(this, function(state){
var id = box.get('emr_id');
var name = box.get('name');
this.emit("tick", {emrId:id, name:name, state:state});
})
}, domConstruct.create("div"));
box.startup();
return box;
}
});
模板
<div class="${baseClass}" data-dojo-attach-point="container" >
<table>
<tbody data-dojo-attach-point="tableBody"></tbody>
</table>
<div class="buttonContainer">
<button class="button" data-dojo-type="dijit.form.Button" data-dojo-attach-point="saveButton">${closeLabel}</button>
</div>
</div>
然后我用调用它,并使用on()从中获取事件。
this.dialog = new emrSelection({store: this.emrStore, emrIds: this.emrIds});
this.dialog.startup();
this.dialog.show();
相关文章:
- 如何检索AMD的XHR响应代码(+时间戳)'大型Dojo
- 如何让我的正则表达式代码在我的dojo cellWidget对象上工作
- Dojo Toolkit中的代码重用
- 恶意软件将代码注入我的Dojo/WebSocket应用程序:如何防止
- 在html代码中加载dojo库
- 为什么 javascript 代码在使用 struts2 和 dojo 的 ajax 请求后不起作用
- 如何将旧版 Dojo 工具包代码转换为 AMD
- Dojo 使用 domConstruct 将声明性代码添加到现有手风琴中
- Dojo.request for iteminfo-在Fiddler中返回代码200,但在浏览器中返回代码0
- onCLickListener Javascript无法在IBM工作灯中使用此dojo代码
- 将语言代码转换为(dojo)区域设置代码
- 将表添加到我的dojo代码中
- Dojo构建如何缩小用ECMASCRIPT5编写的代码
- 是否可以通过代码触发dojo特定的事件
- DOJO:LazyTreeGrid中的Lazy加载节点-查找示例代码
- 如何在Dojo Deferred对象被解析或拒绝后执行常见代码
- 我们如何从dojo.io.iframe.send调用中提取状态代码?
- 在不重复代码的情况下,为不同的Dojo版本以不同的方式声明类
- 为什么这个Dojo 1.9/JS代码不能在Internet Explorer 7中工作?
- 是否已经有现成的代码支持Dojo AMD, NodeJS需求和浏览器窗口.用于Javascript微库