SAPUI5: How can i add a different css class to each FeedList Item? -


i need add different css class each feedlistitem.

i need added each class separately & dynamically (onpost method in js file) since i'm adding different class according feed input entered.

i'v checked sapui5 guide line see no property of feedlistitem related styling&css.

wanted result:

<ul> //feedlistitems   <li class="<my_cutom_class_1>"></li>   <li class="<my_cutom_class_2>"></li>   <li class="<my_cutom_class_3>"></li> </ul> 

what best way it?

how can that?

xml file:

<feedinput     post="onpost"     icon="test-resources/sap/m/images/dronning_victoria.jpg"     class="sapuismallmargintopbottom" /> <list     showseparators="inner"     items="{/entrycollection}" >     <feedlistitem         sender="{author}"         icon="{authorpicurl}"         senderpress="onsenderpress"         iconpress="oniconpress"         icondensityaware="false"         info="{type}"         timestamp="{date}"         text="{text}" /> </list> 

js file:

sap.ui.define([     'jquery.sap.global',     'sap/m/messagetoast',     'sap/ui/core/format/dateformat',     'sap/ui/core/mvc/controller',     'sap/ui/model/json/jsonmodel' ], function(jquery, messagetoast, dateformat, controller, jsonmodel) { "use strict";  var ccontroller = controller.extend("sap.m.sample.feed.c", {      oninit: function () {         // set mock model         var spath = jquery.sap.getmodulepath("sap.m.sample.feed", "/feed.json")         var omodel = new jsonmodel(spath);         this.getview().setmodel(omodel);     },      onpost: function (oevent) {         var oformat = dateformat.getdatetimeinstance({style: "medium"});         var odate = new date();         var sdate = oformat.format(odate);         // create new entry         var svalue = oevent.getparameter("value");         var oentry = {             author : "alexandrina victoria",             authorpicurl : "http://upload.wikimedia.org/wikipedia/commons/a/aa/dronning_victoria.jpg",             type : "reply",             date : "" + sdate,             text : svalue         };          // update model         var omodel = this.getview().getmodel();         var aentries = omodel.getdata().entrycollection;         aentries.unshift(oentry);         omodel.setdata({             entrycollection : aentries         });     }   });   return ccontroller; 

});

edit: version 1.48 it's not possbile set binding property "class". "addstyleclass" , work around work out.

i'm afk , therefore can't validate following. should solve it. in xml view property "class" add feedlistitem. in js controller property object "oentry". , model needs handle class attribute well.

xml view:

<feedinput   post="onpost"   icon="test-resources/sap/m/images/dronning_victoria.jpg"   class="sapuismallmargintopbottom" /> <list   showseparators="inner"   items="{/entrycollection}">   <feedlistitem      class="{class}"      sender="{author}"     icon="{authorpicurl}"     senderpress="onsenderpress"     iconpress="oniconpress"     icondensityaware="false"     info="{type}"     timestamp="{date}"     text="{text}" /> </list> 

controller js:

onpost: function (oevent) {   var oformat = dateformat.getdatetimeinstance({style: "medium"});   var odate = new date();   var sdate = oformat.format(odate);   // create new entry   var svalue = oevent.getparameter("value");   var oentry = {      class: "cssclass",      author : "alexandrina victoria",     authorpicurl : "http://upload.wikimedia.org/wikipedia/commons/a/aa/dronning_victoria.jpg",     type : "reply",     date : "" + sdate,       text : svalue     };     // update model     var omodel = this.getview().getmodel();     var aentries = omodel.getdata().entrycollection;     aentries.unshift(oentry);     omodel.setdata({       entrycollection : aentries     }); } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -