$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: true, vro: true, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content
avatar image
Former Member

Add new rows in the sap ui5 table


I have a table with aggregation property item set as items="{path:'/trackerSet'}". The data is displayed fine on the table. Now i want to add a new row to this table.

Initial model binding in the init is as below:-

this.sServiceUrl = "proxy/_____/sap/opu/odata/SAP/ZEMPLOYEE_SRV/";

this.oModel = new sap.ui.model.odata.ODataModel(

this.sServiceUrl, true, "", "");

var oView = this.getView().setModel(this.oModel);

Can you please advice.



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Mar 06, 2017 at 06:25 PM


    Your JSON model in the view is bit different after this line

    oModel.setData({modelData: vData});

    Above line creates one more parent node with name as modelData and sets the JSON. Below is the final JSON data:

    	"modelData": {
    		"products": [{
    			"product": "Test1",
    			"supplier": "Supp1",
    			"price": "25"
    		}, {
    			"product": "Test2",
    			"supplier": "supp2",
    			"price": "26"

    Change table binding to this...

    <Table id="idProductsTable" inset="false"
               items="{path: '/modelData/products'}">
    Add comment
    10|10000 characters needed characters exceeded

  • Mar 06, 2017 at 01:28 PM

    no possible with odata model. you have to use jsonmodel to do that.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Jun,

      Thanks for suggestion, i was doing through simple way using the JSON model and am stuck on the binding; the table says no data. Can you pin point if anything wrong that i am doing.

      XML View:-




      yh36i.png (27.4 kB)
      soiqs.png (10.9 kB)
  • avatar image
    Former Member
    Mar 06, 2017 at 09:15 PM

    Hello Narayan,

    Add a add button to the toolbar of your table, and in the press event of add button call below method


    And also in success function of read method, copy the odata into json model and bind this model to view

    Hope it works!



    Add comment
    10|10000 characters needed characters exceeded