我一直在尝试让我的 UIAPP 网格根据按钮插入按钮动态添加对象,但似乎无法这样做。我不知道为什么这不起作用。任何帮助将不胜感激。
function trackColumns()
{
var app = UiApp.createApplication().setWidth(500).setHeight(360).setTitle('Step 1: Select Information to Track');
var panel = app.createVerticalPanel().setId("settingsPanel");
var headerpanel = app.createVerticalPanel().setId("headerPanel").setStyleAttribute("background", "silver").setWidth(500);
var columnPanel = app.createVerticalPanel();
var mainGrid = app.createGrid(5, 1).setId("mainGrid");
var columnGrid =app.createGrid(1,1).setId("columnGrid");
var columnspanel = app.createHorizontalPanel().setId("columnspanel");
var columnname = app.createTextBox().setText("Name");
columnspanel.add(columnname);
var addcolumnspanel = app.createHorizontalPanel().setId("addcolumnspanel");
var addbuttonhandler = app.createServerHandler("addcolumn");
addbuttonhandler.addCallbackElement(columnGrid);
var addbutton = app.createButton().setId("btnaddcolumn").setText("Add another column").addClickHandler(addbuttonhandler);
addcolumnspanel.add(addbutton);
columnGrid.setWidget(0, 0, columnspanel);
mainGrid.setWidget(1, 0, columnGrid);
mainGrid.setWidget(2, 0, addcolumnspanel);
panel.add(mainGrid);
app.add(panel);
ss.show(app);
return app;
}
function trackster_addcolumn(e) {
var app = UiApp.getActiveApplication();
var columnspanel = app.createHorizontalPanel().setId("columnspanel");
var columnname = app.createTextBox().setText("Name");
var columntype = app.createListBox();
columntype.addItem("Text");
columntype.addItem("DropDown");
columntype.addItem("Date");
columntype.addItem("Number");
columnspanel.add(columnname);
columnspanel.add(columntype);
var columngrid = e;
columngrid.setWidget(3,0,columnspanel);
return app;
}