Skip to Content
0
Jul 24, 2014 at 12:22 PM

How to bind the data from pop up window to table?

794 Views

Hi All,

I've one doubt, while executing my pro pop up window cme,

see below,

i want aft submit data, the data store in table..i tried lot f time but i cant, help me..

here s my code:

var mdData = {

Employees:[

{firstName:"Pal", lastName:"saran", age:"25",id:"1"},

{firstName:"John", lastName:"pal", age:"25",id:"2" },

]

};

var oModel = new sap.ui.model.json.JSONModel();

oModel.setData(mdData);

sap.ui.getCore().setModel(oModel);

var oTable = new sap.ui.table.Table({

title: "Employees",

visibleRowCount: 7,

firstVisibleRow: 3,

selectionMode: sap.ui.table.SelectionMode.Single,

toolbar: new sap.ui.commons.Toolbar({

items: [

new sap.ui.commons.Button({

text: "Add",

press: function() {

oController.Add();

}

}),

new sap.ui.commons.Button({

text: "Delete",

press: function() {

oController.Delete();

}

}),

new sap.ui.commons.Button({

text: "Update",

press: function() {

oController.Update();

}

})]

})

});

oTable.addColumn(new sap.ui.table.Column({

label: new sap.ui.commons.Label({text: "id"}),

template: new sap.ui.commons.Label({text:"{id}"}),

}));

oTable.addColumn(new sap.ui.table.Column({

label: new sap.ui.commons.Label({text: "First Name"}),

template: new sap.ui.commons.TextField().bindProperty("value", "firstName"),

}));

oTable.addColumn(new sap.ui.table.Column({

label: new sap.ui.commons.Label({text: "Last Name"}),

template: new sap.ui.commons.TextField().bindProperty("value", "lastName"),

}));

oTable.addColumn(new sap.ui.table.Column({

label: new sap.ui.commons.Label({text: "Age"}),

template: new sap.ui.commons.TextField().bindProperty("value", "age"),

}));

oTable.bindRows("/Employees");

var oShell = new sap.ui.ux3.Shell("myShell", {

showLogoutButton: true,

showSearchTool: false,

showFeederTool: false,

showInspectorTool: false,

designType: sap.ui.ux3.ShellDesignType.Light,

content : oTable

});

oShell.placeAt("content");

},

openDialog : function () {

var layoutNew = new sap.ui.commons.layout.MatrixLayout("layout1", {width:"auto"});

var oVal1 = new sap.ui.commons.TextField("cFin",{tooltip: "FirstName", width: "200px", editable:true});

var oVal2 = new sap.ui.commons.TextField("sLan",{tooltip: "lastName", width: "200px", editable:true});

var oVal3 = new sap.ui.commons.TextField("eAge",{tooltip: "Age", width: "200px", editable:true});

var oExcButton = new sap.ui.commons.Button({

text : "Submit",press:function(){

var EmployeesCounter = 3;

var fname = sap.ui.getCore().byId('firstName').getValue();

var lname = sap.ui.getCore().byId('lastName').getValue();

var age = sap.ui.getCore().byId('age').getValue();

mdData.Employees.push({"firstName":fname,"lastName":lname,"age":age,"id":EmployeesCounter++});

oModel.setData(mdData);

alert("Data added successfully");

oDialog1.close();

}});

layoutNew.createRow(new sap.ui.commons.Label({text: "FirstName: "}), oVal1 );

layoutNew.createRow(new sap.ui.commons.Label({text: "LastName: "}), oVal2 );

layoutNew.createRow(new sap.ui.commons.Label({text: "Age: "}), oVal3 );

layoutNew.createRow(new sap.ui.commons.Label(),oExcButton);

var oDialog1 = new sap.ui.commons.Dialog();

oDialog1.setTitle("Enter Persons Details");

oDialog1.setShowCloseButton();

oDialog1.addContent(layoutNew);

oDialog1.open();

}

Attachments

sap1.PNG (30.8 kB)