view
<content>
<Table items="{/Employees}" >
<columns>
<Column>
<Text text="EmployeeID"></Text>
</Column>
<Column>
<Text text="LastName"></Text>
</Column>
<Column minScreenWidth="Tablet">
<Text text="Address"></Text>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="City"></Text>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{EmployeeID}"></Text>
<Input value="{LastName}"></Input>
<Text text="{Address}"></Text>
<Text text="{City}"></Text>
</cells>
</ColumnListItem>
</items>
</Table>
<Input value="{crud>/Country}"></Input>
<Table items="{crud>/}" id="abc" >
<columns>
<Column>
<Text text="EmployeeID"></Text>
</Column>
<Column>
<Text text="LastName"></Text>
</Column>
<Column minScreenWidth="Tablet">
<Text text="Title"></Text>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="FirstName"></Text>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{crud>EmployeeID}"></Text>
<Input value="{crud>LastName}"></Input>
<Text text="{crud>Title}"></Text>
<Text text="{crud>FirstName}"></Text>
</cells>
</ColumnListItem>
</items>
</Table>
</content>
Controller
sap.ui.define([
"sap/ui/core/mvc/Controller"
],
/**
* @param {typeof sap.ui.core.mvc.Controller} Controller
*/
function (Controller) {
"use strict";
return Controller.extend("project123.controller.View1", {
onInit: function () {
// var oModel = new sap.ui.model.odata.v2.ODataModel("/V2/Northwind/Northwind.svc");
// var oThis = this;
// oModel.read("/Employees(1)", {
// success: function (oData) {
// var ocrud = new sap.ui.model.json.JSONModel({
// Country: oData.Country
// });
// oThis.getView().setModel(ocrud, "crud");
// },
// error: function (oData) {
// }
how to get a model in a controller
// var data =this.getOwnerComponent().getModel("raja");
or
var data = this.getView().getModel("raja" );
var json = new JSONModel();
var oThis=this;
data.read("/Customers",{
success: function (oData){
debugger;
json.setData(oData.results);
oThis.getView().byId("abc").setModel(json, "crud");
}
var oModel = new sap.ui.model.odata.v2.ODataModel("/V2/Northwind/Northwind.svc");
var ocrud = new sap.ui.model.json.JSONModel();
var oThis = this;
oModel.read("/Employees", {
success: function (oData) {
ocrud.setData(oData.results);
oThis.getView().byId("abc").setModel(ocrud, "crud");
},
error: function (oData) {
}
});
},
});
})
No comments:
Post a Comment