我有一个如下所示的SmartForm:
<Dialog id="massChangeDialog" title="{i18n>ChangeMaintainanceOrderOperation}" resizable="true" draggable="true" contentWidth="900px"
contentHeight="700px">
<content>
<smartForm:SmartForm id="editOperation" editable="true" entityType="EditOperation">
<smartForm:Group>
<smartForm:GroupElement>
<smartField:SmartField value="{WorkCenter}" id="idWorkCenter" width="90%" class="sapUiSmallMarginBottom"/>
</smartForm:GroupElement>
</smartForm:Group>
<smartForm:Group>
<smartForm:GroupElement>
<smartField:SmartField value="{PersonalNumber}" id="idPersonalNr" width="90%"/>
</smartForm:GroupElement>
</smartForm:Group>
<smartForm:Group>
<smartForm:GroupElement>
<smartField:SmartField value="{ActionDescription}" width="90%" id="idDispatch"/>
</smartForm:GroupElement>
</smartForm:Group>
<smartForm:Group>
<smartForm:GroupElement>
<smartField:SmartField value="{ChangedDate}" id="idDate" width="90%"/>
</smartForm:GroupElement>
</smartForm:Group>
<smartForm:Group>
<smartForm:GroupElement>
<smartField:SmartField value="{ChangedTime}" id="idTime" width="90%" placeholder="{i18n>EnterTime}"/>
</smartForm:GroupElement>
</smartForm:Group>
</smartForm:SmartForm>
</content>
</Dialog>
对话框上下文绑定到odata服务:
if (!this.oDialogChangeOperations) {
// Begin of 0001
this.oDialogChangeOperations = sap.ui.xmlfragment(this.getView().getId(),
"rsh.eam.details1.RSH_EAM_DETS1Extension.view.ChangeOperationsCustom", this);
// End of 0001
//this.getView().addDependent(this.oDialogChangeOperations);
this.oDialogChangeOperations.setModel(this.getModel("EditOp"));
this.byId("MassChange").attachPress(this.onMassChangePressed, this);
this.byId("CloseDialog").attachPress(this.onCloseDialog, this);
this.byId("RestChange").attachPress(this.onResetMassChangePressed, this);
}
模型this.getModel("EditOp")
是一个odata服务。
UI如下所示:
如您在图像上看到的,个人编号充满了价值。如果用户按下重置按钮,如何删除该值?
我尝试过:
this.byId("idPersonalNr").setValueState(sap.ui.core.ValueState.None);
this.byId("idPersonalNr").setValue('0');
和
this.oDialogChangeOperations.getModel().setProperty("/PersonalNumber", this.intialPerson);
this.oDialogChangeOperations.getModel().refresh();
它根本不起作用。
答案 0 :(得分:0)
您可以使用模型的setData
方法来设置值。
这是我在JS Bin中为您创建的示例。
示例中的JSON模型具有绑定到PersonnelNo
控件的2个属性OtherInfo
和sap.m.Input
。点击Reset
按钮,然后执行以下操作
oJsonModel.setData({PersonnelNo:null},true);
由于在方法结束时的PersonnelNo
值,OtherInfo
被清除并且true
属性未被更改,这意味着更改被合并到模型中而不是重写输入模型数据。您还可以同时设置多个值。
答案 1 :(得分:0)
我发现可以在对话框中使用smartFroms的方法是:
如果已设置元素的绑定,请使用.unbindElement()
。当然,这意味着您必须在需要时再次绑定它。
可以使用模型上的oData模型.resetChanges()
。您还可以指出应重置为参数的路径。
希望有帮助, Shanir