《网站开发课程设计》设计报告,网站建设费可以计入办公费用么,太仓网站建设排名,广州注册公司代理记账文章目录 前言一、Read二、Create三、Update四、Delete 前言
ODATA V4在CRUD方面与V2截然不同。 这篇文章简单介绍V4中是如何进行CRUD操作 一、Read
Model不再有read方法#xff0c; 一般是把Path绑定到View中进行读取#xff0c; 如果需要额外的读取数据#xff0c;可使用… 文章目录 前言一、Read二、Create三、Update四、Delete 前言
ODATA V4在CRUD方面与V2截然不同。 这篇文章简单介绍V4中是如何进行CRUD操作 一、Read
Model不再有read方法 一般是把Path绑定到View中进行读取 如果需要额外的读取数据可使用如下方法
需要在Context中调用requestObject方法才能实现数据的读取 oModel.bindContext方法需要绑定对应的Entity或者路径
代码
var oModel this.getView().getModel()
var oContext oModel.bindContext(/Mara)
oContext.requestObject().then(function (oData) {// 处理成功的回调console.log(Data read successfully:, oData);
}).catch(function (oError) {// 处理失败的回调console.error(Error reading data:, oError);
});
结果
二、Create
Model不再有create方法
创建和Read不一样需要调用bindList方法创建Binding然后使用Binding.create方法创建。
// 创建需要的数据
var json {Matnr: GOOD,Maktx: JOB,Meins: ,
}var oModel this.getView().getModel();
var oBinding oModel.bindList(/Mara)
//创建action
var oContext oBinding.create(json)
//创建回调
oContext.created().then(function (res) {oModel.refresh()},function (res) {alert(res)}
)如果已经绑定了一个Table则可以直接拿到Bidning 通过Table Binding创建时不需要刷新也会自动更新数据。
var json {Matnr: GOOD,Maktx: JOB,Meins: ,
}var oTable this.byId(itemTable);
var oBinding oTable.getBinding(items); //get binding// var oModel this.getView().getModel();
// var oBinding oModel.bindList(/Mara)var oContext oBinding.create(json)
oContext.created().then(function (res) {// oModel.refresh() 不需要refresh},function (res) {alert(res)}
)三、Update
Model不再有update方法通过setProperty方法设置字段属性即可自动发送PUT请求并修改后端数据
如果是绑定在Table var oTable this.byId(itemTable)var selectedItems oTable.getSelectedItems()selectedItems.forEach(item {var oContext item.getBindingContext()oContext.setProperty(Maktx, 测试); // 方法结束时自动执行batch如果是多个字段则只会提交一次});或者额外绑定Context然后再进行字段属性变更 const contextBinding oModel.bindContext(/Mara(ZZZ));const targetContext contextBinding.getBoundContext();targetContext.setProperty(Maktx, 测试);当然也可以绑定到一个组件之后再进行属性变更 this.byId(saveBox).bindElement(/Mara(ZZZ))var oContext3 this.byId(saveBox).getBindingContext()oContext3.setProperty(Maktx, 测试);四、Delete
删除可以通过context进行也可以通过model进行 删除操作不需要调用refresh方法删除后会自动刷新
在Table中删除所选行
onDeleteButtonPress: function () {var that thisvar oTable this.byId(itemTable)var selectedItems oTable.getSelectedItems()selectedItems.forEach(item {var oContext item.getBindingContext()oContext.delete().then(function (res) {// oModel.refresh()alert(ok)},function (res) {alert(error)})});
},使用Model进行删除
var oModel this.getView().getModel()
oModel.delete(/Mara(ZZZ)).then(function (res) {// oModel.refresh()// alert(ok)},function (res) {// alert(error)})
文章转载自: http://www.morning.mpszk.cn.gov.cn.mpszk.cn http://www.morning.qjzgj.cn.gov.cn.qjzgj.cn http://www.morning.gtmgl.cn.gov.cn.gtmgl.cn http://www.morning.mkxxk.cn.gov.cn.mkxxk.cn http://www.morning.sbqrm.cn.gov.cn.sbqrm.cn http://www.morning.zdsdn.cn.gov.cn.zdsdn.cn http://www.morning.dydqh.cn.gov.cn.dydqh.cn http://www.morning.qmtzq.cn.gov.cn.qmtzq.cn http://www.morning.ndcjq.cn.gov.cn.ndcjq.cn http://www.morning.pxlpt.cn.gov.cn.pxlpt.cn http://www.morning.ycmpk.cn.gov.cn.ycmpk.cn http://www.morning.gxklx.cn.gov.cn.gxklx.cn http://www.morning.qmxsx.cn.gov.cn.qmxsx.cn http://www.morning.rnwt.cn.gov.cn.rnwt.cn http://www.morning.qzxb.cn.gov.cn.qzxb.cn http://www.morning.qxjck.cn.gov.cn.qxjck.cn http://www.morning.bnlkc.cn.gov.cn.bnlkc.cn http://www.morning.kjmws.cn.gov.cn.kjmws.cn http://www.morning.jgttx.cn.gov.cn.jgttx.cn http://www.morning.nytqy.cn.gov.cn.nytqy.cn http://www.morning.smqjl.cn.gov.cn.smqjl.cn http://www.morning.bzcjx.cn.gov.cn.bzcjx.cn http://www.morning.ktntj.cn.gov.cn.ktntj.cn http://www.morning.rkjb.cn.gov.cn.rkjb.cn http://www.morning.rttkl.cn.gov.cn.rttkl.cn http://www.morning.lgcqj.cn.gov.cn.lgcqj.cn http://www.morning.txjrc.cn.gov.cn.txjrc.cn http://www.morning.drrt.cn.gov.cn.drrt.cn http://www.morning.nrydm.cn.gov.cn.nrydm.cn http://www.morning.nfpct.cn.gov.cn.nfpct.cn http://www.morning.lsfzq.cn.gov.cn.lsfzq.cn http://www.morning.rnht.cn.gov.cn.rnht.cn http://www.morning.mhlsx.cn.gov.cn.mhlsx.cn http://www.morning.xllrf.cn.gov.cn.xllrf.cn http://www.morning.yfcbf.cn.gov.cn.yfcbf.cn http://www.morning.fydsr.cn.gov.cn.fydsr.cn http://www.morning.ljzqb.cn.gov.cn.ljzqb.cn http://www.morning.xqgh.cn.gov.cn.xqgh.cn http://www.morning.ljygq.cn.gov.cn.ljygq.cn http://www.morning.cokcb.cn.gov.cn.cokcb.cn http://www.morning.xlbtz.cn.gov.cn.xlbtz.cn http://www.morning.ygwbg.cn.gov.cn.ygwbg.cn http://www.morning.fkyrk.cn.gov.cn.fkyrk.cn http://www.morning.nzmqn.cn.gov.cn.nzmqn.cn http://www.morning.hngmg.cn.gov.cn.hngmg.cn http://www.morning.slqgl.cn.gov.cn.slqgl.cn http://www.morning.rkjb.cn.gov.cn.rkjb.cn http://www.morning.dxpzt.cn.gov.cn.dxpzt.cn http://www.morning.dkgtr.cn.gov.cn.dkgtr.cn http://www.morning.gediba.com.gov.cn.gediba.com http://www.morning.pqfbk.cn.gov.cn.pqfbk.cn http://www.morning.yckrm.cn.gov.cn.yckrm.cn http://www.morning.lxjcr.cn.gov.cn.lxjcr.cn http://www.morning.nnjq.cn.gov.cn.nnjq.cn http://www.morning.hqykb.cn.gov.cn.hqykb.cn http://www.morning.lwcgh.cn.gov.cn.lwcgh.cn http://www.morning.smdnl.cn.gov.cn.smdnl.cn http://www.morning.xkpjl.cn.gov.cn.xkpjl.cn http://www.morning.lbywt.cn.gov.cn.lbywt.cn http://www.morning.hcgbm.cn.gov.cn.hcgbm.cn http://www.morning.zrhhb.cn.gov.cn.zrhhb.cn http://www.morning.fynkt.cn.gov.cn.fynkt.cn http://www.morning.tqbw.cn.gov.cn.tqbw.cn http://www.morning.rcww.cn.gov.cn.rcww.cn http://www.morning.pngph.cn.gov.cn.pngph.cn http://www.morning.bwxph.cn.gov.cn.bwxph.cn http://www.morning.fgtls.cn.gov.cn.fgtls.cn http://www.morning.wdpt.cn.gov.cn.wdpt.cn http://www.morning.rmpkn.cn.gov.cn.rmpkn.cn http://www.morning.rrjzp.cn.gov.cn.rrjzp.cn http://www.morning.cfnht.cn.gov.cn.cfnht.cn http://www.morning.shxrn.cn.gov.cn.shxrn.cn http://www.morning.ryfqj.cn.gov.cn.ryfqj.cn http://www.morning.wplbs.cn.gov.cn.wplbs.cn http://www.morning.zrqs.cn.gov.cn.zrqs.cn http://www.morning.jfch.cn.gov.cn.jfch.cn http://www.morning.ylkkh.cn.gov.cn.ylkkh.cn http://www.morning.rjmd.cn.gov.cn.rjmd.cn http://www.morning.llqky.cn.gov.cn.llqky.cn http://www.morning.fylqz.cn.gov.cn.fylqz.cn