对于Command、Menu和DropDown来说,他们在页面是不可见的,必须需要其它可见的控件来绑定才发挥他们的作用。所以这样控件可以通过客户端代码来动态生成使用:
MarmotQuery.prototype._getCommandSaveQuerySchema = function () {
var datasetParameter = this._getDatasetQueryParameter();
if (__queryCondition2Parameter(this.conditionDataset, datasetParameter)) {
var command = getControl("$commandSaveQuerySchema");
if (!command) {
command = DoradoFactory.create("MarmotUpdateCommand", null, "$commandSaveQuerySchema");
command.setAction(__MARMOT_DEFAULT_UPDATE_ACTION);
command.setResolver("marmot.queryBoxBackBean");
command.setMethod("replaceQueryQuickly");
command.setAsync(true);
var marmotQuery = this;
EventManager.addDoradoEvent(command, "beforeExecute", function (command) {
var parameters = command.parameters();
var queryName = parameters.getValue("queryName");
if (!parameters.getValue("overwrite") && queryName) {
var dataset = marmotQuery._getDatasetQuery();
dataset.clearData();
dataset.insertRecord();
dataset.setValue("queryName", queryName);
dataset.postRecord();
}
});
EventManager.addDoradoEvent(command, "onSuccess", function (command) {
if (!command.parameters().getValue("overwrite")) {
marmotQuery.refreshSchemaMenuItems();
}
});
command.activate();
}
return command;
}
else {
return null;
}
} |
代码 5.1:客户端创建Control