Skip to Content
0
Sep 26, 2014 at 12:48 PM

Add/Insert row to SAPUI5 Table Dynamically

2242 Views

Dear All Gurus,

I need to create a UI5 table (Empty) to add records manually. Below is my coding..

Requirement : When user click on AddNew button on the table , a new row will be added.a new row will be added with LineItem Column id incremental.


var oTable = new sap.ui.table.Table({
title: "Line Items",
visibleRowCount: 7,
firstVisibleRow: 3,
  selectionMode: sap.ui.table.SelectionMode.Single,
  toolbar: new sap.ui.commons.Toolbar({items: [ 
  new sap.ui.commons.Button({
  text: "Addnew", 
  style: sap.ui.commons.ButtonStyle.Accept,
  press: function() {addnew(); }})
  ]}),
});

oTable.addColumn(new sap.ui.table.Column({
  label: new sap.ui.commons.Label({text: "LineItem"}),
  sortProperty: "LineItem",
  filterProperty: "LineItem",
  width: "200px"
  }));

  oTable.addColumn(new sap.ui.table.Column({
  label: new sap.ui.commons.Label({text: "AccAss"}),
  sortProperty: "AccAss",
  filterProperty: "AccAss",
  width: "200px"
  }));

  oTable.addColumn(new sap.ui.table.Column({
  label: new sap.ui.commons.Label({text: "material"}),
  sortProperty: "material",
  filterProperty: "material",
  width: "200px"
  }));

function addnew(){

  • How to add an Empty row to enter values?
  • How to auto increment the line id?


} a