使用CRUD保存数据后,我想重新加载“菜单”页面。
var sUrl = "/sap/opu/odata/sap/ZGW_VISTORIA_SRV";
var oModel = new sap.ui.model.odata.ODataModel(sUrl, true);
var rota = this.getOwnerComponent().getRouter();
var page = this;
oModel.create('/vistoria', dados, null,
function () {
MessageBox.success('Cadastrado com sucesso!', {
onClose: function (sActionClicked) {
oStorage.clear();
oStorage.removeAll();
// oStorage.put("Save", {
// isSave: true
// });
page.getView().exit();
page.getView().destroy();
// oStorage.get("Menu").menu.getModel().refresh(true);
rota.navTo("Menu", false);
// window.location.reload(window.history.go(-3));
// sap.ui.getCore().byId("Menu").getModel().refresh(true);
}
});
},
function () {
MessageBox.error('Erro ao cadastrar o veiculo!');
}
);
我以多种方式尝试了此操作,因为我需要删除保存在表单中的信息。 所以,你能帮我吗?
答案 0 :(得分:0)
首先,如果您下次发布所有与您相关的代码(也包括表单),那就太好了,
但我想我知道你想做什么。
(重置表单,不重新加载页面)
(重新加载整个view
比重新设置form
会花费更长的时间)
一种方法是绑定模型中表单内的input
/ checkbox
等值:
<Input
id="someID"
value="{urModel>/inputValue}"
valueState="{vsModel>/vsInput}"
valueStateText="{i18n>vstInput}"/>
然后在您成功的方法或您的创建中重置这些值:
urRemoteModel.create("/urSet", oEntry, {
success: function(oRetrievedResult) {
this.getView().getModel(urModel).setProperty("/inputValue", "");
//some other stuff
}.bind(this),
error: function(oError) {
//error handling
}
});
答案 1 :(得分:0)
抱歉,我延迟了。 我正在创建一个用于检查卡车的应用程序。当用户结束调查并保存时,他将被重定向到“菜单”页面。
在该页面中,他可以单击“ Cadastrar”图块来选择进行新的调查。这里有必须清除的表格:
<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:form="sap.ui.layout.form" xmlns:core="sap.ui.core"
controllerName="com.sap.build.standard.formInspecaoDeVeiculos.controller.Identificacao">
<Page showHeader="true" title="Indenificação" showFooter="true" showNavButton="true" navButtonPress="_onPageNavButtonPress">
<content>
<Panel height="auto" width="auto" headerText="" expandable="false" expanded="true" expandAnimation="true" backgroundDesign="Solid"
class="sapUiTinyMargin sapUiContentPadding">
<content>
<form:Form width="100%" editable="true" visible="true">
<form:title>
<core:Title text="Veículo" level="Auto"/>
</form:title>
<form:formContainers>
<form:FormContainer visible="true">
<form:formElements>
<form:FormElement visible="true">
<form:label>
<Label text="Veículo" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit" visible="true"/>
</form:label>
<form:fields>
<Input id="tratorInput" placeholder="Ex.: ABC1234" type="Text" showValueHelp="true" enabled="true" visible="true" width="auto"
valueHelpOnly="false" maxLength="0" valueHelpRequest="handleValueHelp" suggestionItems="{/Veiculo}"
value="{ path : '/placa', type : '.customPlacaType' }" valueLiveUpdate="{/ValueLiveUpdate}" liveChange="handleLiveChange">
<suggestionItems>
<core:Item text="{Placa}"/>
</suggestionItems>
</Input>
</form:fields>
</form:FormElement>
<form:FormElement visible="true">
<form:label>
<Label text="Reboque(1)" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit" visible="true"/>
</form:label>
<form:fields>
<Input id="reboque1Input" placeholder="Ex.: ABC1234" type="Text" showValueHelp="true" enabled="true" visible="true" width="auto"
valueHelpOnly="false" maxLength="0" valueHelpRequest="handleValueHelp" suggestionItems="{/Reboque}"
value="{ path : '/placa', type : '.customPlacaType' }" valueLiveUpdate="{/ValueLiveUpdate}" liveChange="handleLiveChange">
<suggestionItems>
<core:Item text="{Placa}"/>
</suggestionItems>
</Input>
</form:fields>
</form:FormElement>
<form:FormElement visible="true">
<form:label>
<Label text="Reboque(2)" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit" visible="true"/>
</form:label>
<form:fields>
<Input id="reboque2Input" placeholder="Ex.: ABC1234" type="Text" showValueHelp="true" enabled="true" visible="true" width="auto"
valueHelpOnly="false" maxLength="0" valueHelpRequest="handleValueHelp" suggestionItems="{/Reboque}"
value="{ path : '/placa', type : '.customPlacaType' }" valueLiveUpdate="{/ValueLiveUpdate}" liveChange="handleLiveChange">
<suggestionItems>
<core:Item text="{Placa}"/>
</suggestionItems>
</Input>
</form:fields>
</form:FormElement>
<form:FormElement visible="true">
<form:label>
<Label text="Motorista" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit" visible="true"/>
</form:label>
<form:fields>
<Input id="motoristaInput" placeholder="Ex.: Nome do motorista" type="Text" showValueHelp="true" enabled="true" visible="true" width="auto"
valueHelpOnly="false" maxLength="0" valueHelpRequest="handleValueHelp" suggestionItems="{/Motorista}" valueLiveUpdate="{/ValueLiveUpdate}"
liveChange="handleLiveChange" value="{ path : '/Name1', type: '' }">
<suggestionItems>
<core:Item text="{Name1}"/>
</suggestionItems>
</Input>
</form:fields>
</form:FormElement>
<form:FormElement visible="true">
<form:label>
<Label text="CPF" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit" visible="true"/>
</form:label>
<form:fields>
<Input id="cpfInput" placeholder="Ex.: 00000000000" type="Text" showValueHelp="true" enabled="true" visible="true" width="auto"
valueHelpOnly="false" maxLength="0" valueHelpRequest="handleValueHelp" suggestionItems="{/Motorista}" valueLiveUpdate="{/ValueLiveUpdate}"
liveChange="handleLiveChange">
<suggestionItems>
<core:Item text="{Stcd2}"/>
</suggestionItems>
</Input>
</form:fields>
</form:FormElement>
</form:formElements>
<form:title/>
</form:FormContainer>
</form:formContainers>
<form:layout>
<form:ResponsiveGridLayout adjustLabelSpan="false" columnsL="2" labelSpanL="3" columnsM="1" labelSpanM="2" labelSpanS="12"/>
</form:layout>
</form:Form>
</content>
</Panel>
</content>
<footer>
<OverflowToolbar width="100%" height="auto" design="Auto" enabled="true" visible="true">
<content>
<ToolbarSpacer width=""/>
<Button text="" type="Emphasized" icon="sap-icon://navigation-right-arrow" iconFirst="true" width="auto" enabled="true" visible="true"
iconDensityAware="false" press="_onContinue"/>
</content>
</OverflowToolbar>
</footer>
<headerContent/>
<subHeader/>
<customHeader/>
</Page>
在我的输入中,我使用“ path:/ placa”设置了属性值,因为我使用辅助进行搜索。在下一页“ Conclusao”中,用户可以在其中完成调查。我的问题:如何从其他页面的页面访问模型?