SAPUI5 - How to change style of FeedListItem according to the model data? -
i have feedlist in xml :
<list id="msglist" showseparators="inner" items="{msgdata>/msgdata}" > <feedlistitem sender="{msgdata>username}" icon="{msgdata>userpicture}" senderpress="onsenderpress" iconpress="oniconpress" icondensityaware="false" info="{msgdata>type}" timestamp="{msgdata>date}" text="{msgdata>text}" class="{msgdata>type}" maxcharacters="1000"/> and need each feed item change style according data receive model
var odate = new date(); var msgdata = { msgdata:[{ title: "", text: "loading...", username: "aytee", userpicture:"image.png" }]}; var omodelmockintention = new jsonmodel(msgdata); this.fragment.setmodel(omodelmockintention, "msgdata"); what best way it?
you can have formatter in text property of feedlistitem , in method can use instance , use addstyleclass , removestyleclass methods update style of particular feedlistitem mentioned below:
<list id="msglist" showseparators="inner" items="{msgdata>/msgdata}" > <feedlistitem sender="{msgdata>username}" icon="{msgdata>userpicture}" senderpress="onsenderpress" iconpress="oniconpress" icondensityaware="false" info="{msgdata>type}" timestamp="{msgdata>date}" text="{parts: ['msgdata>text', 'msgdata>type'],formatter:'.updatecolor'}" maxcharacters="1000"/> inside controller of view can have method mentioned below:
updatecolor:function(text, type){ this.addstyleclass(type); return text; }
Comments
Post a Comment