javascript - How to use SAP OpenUI5 to display table in frontend? -


i newer sap openui5. want display table in frontend, here code:

test.view:

    var opanel = new sap.ui.commons.panel("panel",{text:"calculated fields"});       var tabledata = {          "teammembers":[              {"firstname":"clark", "lastname":"kent", "gender":"male", "occupation":"superman","enable": true},              {"firstname":"donald", "lastname":"duck", "gender":"male", "occupation":"a millionare","enable": true},             {"firstname":"marge", "lastname":"simpson", "gender":"female", "occupation":"a housewife","enable": false},             {"firstname":"jane", "lastname":"marple", "gender":"female", "occupation":"a detective","enable": true},             {"firstname":"tony", "lastname":"stark", "gender":"male", "occupation":"ironman","enable": true},             {"firstname":"james", "lastname":"kirk", "gender":"male", "occupation":"a starfleet captain","enable": true},             {"firstname":"hermione", "lastname":"granger", "gender":"female", "occupation":"a witch","enable": false}]};      var omodel = new sap.ui.model.json.jsonmodel(tabledata);     var otable = new sap.ui.table.table("table",{visiblerowcount: 7});      otable.addcolumn(new sap.ui.table.column("firstname",{         label: new sap.ui.commons.label({ text: "first name" }),          template: new sap.ui.commons.textarea({          value: "{firstname}",         change: ocontroller.handletextareachange             }),          width: "50px",         name: "firstname1"}));     otable.addcolumn(new sap.ui.table.column("lastname",{         label: new sap.ui.commons.label({ text: "last name" }),          template: new sap.ui.commons.textarea({         value: "{lastname}",         change: ocontroller.handletextareachange             }),          width: "50px",         name: "lastname1"}));     otable.addcolumn(new sap.ui.table.column({         label: new sap.ui.commons.label({ text: "enable" }),          template: new sap.ui.commons.checkbox({             checked: "{enable}",             change: ocontroller.handlecheckboxchange             }),          width: "50px" }));      otable.setmodel(omodel);     otable.bindrows("/teammembers");      opanel.addcontent(otable);       return opanel; 

test.controller:

sap.ui.controller("testtomcat.testtomcat", {     handlecheckboxchange: function(oevent){         alert("chackbox changed");         },     handletextareachange: function(oevent){         alert("textarea changed");     } } 

the question is:

  1. the function handlecheckboxchange , handletextareachange have defined template. want define function triggered when change value in textarea or checkbox, can achieve it?

  2. additionally, want check if user input in table legal, in other words,i want handle wrong user input, there better ideas achieve it?

please me, thank much.

first of template specified column makes clones each row. if change of textarea or checkbox , handler triggered. when handler called can play oevent object.

handletextareachange: function(oevent){         var ochangedtextarea  = oevent.getsource();           //now can handle event           //for example          var sgiventext  = ochangedtextarea.getvalue();          if(sgiventext.trim().length<30){              alert("minimum 30 characters required")          }       } 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -