Helloooo专家,
我有一个对话框,我用它来创建和更新条目。一切都很好,除了一点点(但仍然很烦人)。
当我为现有条目调用对话框时,一切都很顺利。字段正常显示,更新工作正常。
当我调用对话框创建一个新条目时,我得到一组空白字段,我填写所有字段,按保存并正常工作。问题出在哪儿?其中一个字段应该已经有一个值,因为我已经使用oModel.createEntry方法赋值。我调试应用程序的条目属性看起来没问题,一切似乎都没问题(如果不是盲目的),但值不是随着字段 - 响铃任何铃声?
下面附带的代码(相当简短),有疑问的字段:iAgrId。
谢谢!
格雷格
onActionAdd: function() {
var oModel = this.getView().getModel();
//oModel.createEntry("/Agreement_ActionsSet");
var oActionEditDialog = new Dialog({title: "Create Action"});
this.createActionFormData(oActionEditDialog, oModel);
//get Agreement ID
var sAgreement = this.getView().getBindingContext().toString().slice(16,26);
var oNewObject = "{\"AgrId\": \"" + sAgreement + "\"}";
oNewObject = JSON.parse(oNewObject);
this.getView().addDependent(oActionEditDialog);
var oEntry = oModel.createEntry("/Agreement_ActionsSet", oNewObject);
oActionEditDialog.setBindingContext(oEntry);
//oActionEditDialog.bindElement(oEntry);
oActionEditDialog.open();
},
onActionEdit: function(oSourceEvent) {
var oModel = this.getView().getModel();
var oActionEditDialog = new Dialog({title: "Edit Action Details"});
this.createActionFormData(oActionEditDialog, oModel);
//to get access to the global model
var sPath = oSourceEvent.getSource().getParent().getBindingContext().toString();
this.getView().addDependent(oActionEditDialog);
oActionEditDialog.bindElement(sPath);
oActionEditDialog.open();
},
// populate form fields
createActionFormData: function(oActionEditDialog, oModel) {
var oActionTypeItemTemplate = new sap.ui.core.ListItem({ key:"{f4>AgrActtypeid}", text:"{f4>AgrActtypeid}", additionalText:"{f4>AgrActtypetxt}"});
var oActionStatusItemTemplate = new sap.ui.core.ListItem({ key:"{f4>AgrStatid}", text:"{f4>AgrStatid}", additionalText:"{f4>AgrStattxt}"});
var oActionAgentItemTemplate = new sap.ui.core.ListItem({ key:"{f4>AgrAgentid}", text:"{f4>AgrAgentid}", additionalText:"{f4>AgrAgenttxt}"});
var sAgrId = new sap.m.Label({text: "{i18n>actionAgrId}"});
var iAgrId = new sap.m.Input({value: "{AgrId}"});
var sAgrActionid = new sap.m.Label({text: "{i18n>actionLineItemTableIDColumn}"});
var iAgrActionid = new sap.m.Input({value: "{AgrActionid}", enabled: false});
var sCreatedBy = new sap.m.Label({text: "{i18n>actionCreatedBy}"});
var iCreatedBy = new sap.m.Input({value: "{CreatedBy}"});
var sCreatedOn = new sap.m.Label({text: "{i18n>actionCreatedOn}"});
var iCreatedOn = new sap.m.DatePicker({value: "{ path: 'CreatedOn', type:'sap.ui.model.type.Date', formatOptions: { style: 'medium', strictParsing: true} }"});
var sActionComment = new sap.m.Label({text: "{i18n>actionComment}"});
var iActionComment = new sap.m.Input({value: "{ActionComment}"});
var sAgrActionDate = new sap.m.Label({text: "{i18n>actionActionDate}"});
var iAgrActionDate = new sap.m.DatePicker({value: "{ path: 'AgrActionDate', type:'sap.ui.model.type.Date', formatOptions: { style: 'medium', strictParsing: true} }"});
var sAgrChaseDate = new sap.m.Label({text: "{i18n>actionChaseDate}"});
var iAgrChaseDate = new sap.m.DatePicker({value: "{ path: 'AgrChaseDate', type:'sap.ui.model.type.Date', formatOptions: { style: 'medium', strictParsing: true} }"});
var sAgrActtypeid = new sap.m.Label({text: "{i18n>actionActionType}"});
var iAgrActtypeid = new sap.m.ComboBox({
//id: "cbRoleType",
selectedKey: "{AgrActtypeid}",
//selectedItemId: "{AgrRoletptxt}",
showSecondaryValues : true,
items: {
path: "f4>/Action_TypesSet",
template: oActionTypeItemTemplate,
templateShareable: "false"}
}).bindProperty("value", "AgrActtypeid");
var sAgrStatidFrom = new sap.m.Label({text: "{i18n>actionStatusFrom}"});
var iAgrStatidFrom = new sap.m.ComboBox({
//id: "cbRoleType",
selectedKey: "{AgrStatidFrom}",
//selectedItemId: "{AgrRoletptxt}",
showSecondaryValues : true,
items: {
path: "f4>/Agreement_StatusesSet",
template: oActionStatusItemTemplate,
templateShareable: "false"}
}).bindProperty("value", "AgrStatidFrom");
var sAgrStatidTo = new sap.m.Label({text: "{i18n>actionStatusTo}"});
var iAgrStatidTo = new sap.m.ComboBox({
//id: "cbRoleType",
selectedKey: "{AgrStatidTo}",
//selectedItemId: "{AgrRoletptxt}",
showSecondaryValues : true,
items: {
path: "f4>/Agreement_StatusesSet",
template: oActionStatusItemTemplate,
templateShareable: "false"}
}).bindProperty("value", "AgrStatidTo");
var sAgrAgentidFrom = new sap.m.Label({text: "{i18n>actionAgentFrom}"});
var iAgrAgentidFrom = new sap.m.ComboBox({
//id: "cbRoleType",
selectedKey: "{AgrAgentidFrom}",
//selectedItemId: "{AgrRoletptxt}",
showSecondaryValues : true,
items: {
path: "f4>/Agreement_AgentsSet",
template: oActionAgentItemTemplate,
templateShareable: "false"}
}).bindProperty("value", "AgrAgentidFrom");
var sAgrAgentidTo = new sap.m.Label({text: "{i18n>actionAgentTo}"});
var iAgrAgentidTo = new sap.m.ComboBox({
//id: "cbRoleType",
selectedKey: "{AgrAgentidTo}",
//selectedItemId: "{AgrRoletptxt}",
showSecondaryValues : true,
items: {
path: "f4>/Agreement_AgentsSet",
template: oActionAgentItemTemplate,
templateShareable: "false"}
}).bindProperty("value", "AgrAgentidTo");
var oSaveButton = new sap.ui.commons.Button({
text: "Save",
press: function (oEvent) {
oModel.submitChanges({
success: function(oData, sResponse) {
},
error: function(oError) {
jQuery.sap.log.error("oData Failure", oError);
}
});
oEvent.getSource().getParent().close();
}
});
var oCancelButton = new sap.ui.commons.Button({
text: "Cancel",
press: function (oEvent) {
oModel.resetChanges();
oEvent.getSource().getParent().close();
}
});
oActionEditDialog.addContent(sAgrId);
oActionEditDialog.addContent(iAgrId);
oActionEditDialog.addContent(sAgrActionid);
oActionEditDialog.addContent(iAgrActionid);
oActionEditDialog.addContent(sCreatedBy);
oActionEditDialog.addContent(iCreatedBy);
oActionEditDialog.addContent(sCreatedOn);
oActionEditDialog.addContent(iCreatedOn);
oActionEditDialog.addContent(sActionComment);
oActionEditDialog.addContent(iActionComment);
oActionEditDialog.addContent(sAgrActionDate);
oActionEditDialog.addContent(iAgrActionDate);
oActionEditDialog.addContent(sAgrChaseDate);
oActionEditDialog.addContent(iAgrChaseDate);
oActionEditDialog.addContent(sAgrActtypeid);
oActionEditDialog.addContent(iAgrActtypeid);
oActionEditDialog.addContent(sAgrStatidFrom);
oActionEditDialog.addContent(iAgrStatidFrom);
oActionEditDialog.addContent(sAgrStatidTo);
oActionEditDialog.addContent(iAgrStatidTo);
oActionEditDialog.addContent(sAgrAgentidFrom);
oActionEditDialog.addContent(iAgrAgentidFrom);
oActionEditDialog.addContent(sAgrAgentidTo);
oActionEditDialog.addContent(iAgrAgentidTo);
oActionEditDialog.addContent(oSaveButton);
oActionEditDialog.addContent(oCancelButton);
},
答案 0 :(得分:0)
问题出现在createEntry方法的参数定义中,正确的声明如下:
var oEntry = oModel.createEntry(“/ Agreement_ActionsSet”,{properties:oNewObject});