我以编程方式开发TableContainer。 当我按下一个按钮时,它会在此TableContent中动态添加一个新行。 如果我按下它,这个新行有一个删除它的按钮。
HTML
<div id="formTableContent" class="tblForm"></div>
的Javascript
var _tableForm = null;
_onLoad : function() {
this._tableForm = new dojox.layout.TableContainer(
{
cols : 3,
customClass :"labelsAndValues",
"labelWidth" : "100"
}, dojo.byId("formTableContent")
);
this._tableForm.startup();
},
// This method add a new row in TableContainer
_createRow : function() {
var txtBox1 = new dijit.form.TextBox({ label : "textlabel1" });
var txtBox2 = new dijit.form.TextBox({ label : "textlabel2" });
var btnDelete = new dijit.form.Button({ label : "Delete", spanLabel : true, iconClass : "removeIcon" });
dojo.connect(btnDelete, "onClick", this, function(evt) {
var row = evt.path[5];
row.parentNode.removeChild(row);
});
this._tableForm.addChild(txtBox1);
this._tableForm.addChild(txtBox2);
this._tableForm.addChild(btnDelete);
this._tableForm._initialized = false;
this._tableForm._started = false;
this._tableForm.startup();
},
图片示例
如果&#39; onClick &#39;我试过这样做:
dojo.connect(btnDelete, "onClick", this, function(evt){
var row = evt.path[5];
row.parentNode.removeChild(row);
});
它会检测行,但是当我添加一个新行时,在TableContainer中会显示删除的行并添加新行。
答案 0 :(得分:0)
I know it's an old post but this might helps others. TableContainer has a method removeChild(child) and if you use this, the row will be deleted and it will not reappear when you add a new row.