<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Set class dynamically via odata binding in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/set-class-dynamically-via-odata-binding/qaa-p/584107#M133708</link>
    <description>&lt;P&gt;Hello GB,&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;thank you very much for this hint. I actually found a solution using customData property. In the view I use:&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;VBox class="defaultStyle"&amp;gt;
    &amp;lt;customData&amp;gt;
        &amp;lt;core:CustomData key="status-snr" value="status{oDataModel&amp;gt;StatusSnr}" writeToDom="true"&amp;gt;
    &amp;lt;customData&amp;gt;&lt;BR /&gt;... &lt;BR /&gt;&amp;lt;/VBox&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;and in the style.css I have an attribute selector:&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;.defaultStyle {
    background-color: lightgrey;
}

[data-status-snr="status10"] {
  background-color: lightgreen;
}&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;So when {oDataModel&amp;gt;StatusSnr} is evaluated to '10' the attribute data-status-snr will have value of 10 und therefore background-color is lightgreen.&lt;/P&gt;
  &lt;P&gt;Regards&lt;/P&gt;
  &lt;P&gt;Christian&lt;/P&gt;</description>
    <pubDate>Wed, 25 Apr 2018 12:49:21 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2018-04-25T12:49:21Z</dc:date>
    <item>
      <title>Set class dynamically via odata binding</title>
      <link>https://community.sap.com/t5/technology-q-a/set-class-dynamically-via-odata-binding/qaq-p/584105</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;According to the value of an odata entity property I want to set the css class of a Text control. I tried this:&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;Text class="status{oDataModel&amp;gt;StatusSnr}" .../&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;In the style.css file I will have some classes with different background-color. For instance:&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;.status10 {background-color: lightgreen; }&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;However, it seems that the odata binding will not be evaluated. When I run my app and inspect the elements with F12 the text element is still shown with:&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;span id="__text41" data-sap-ui="__text41" class="sapMText sapUiSelectable status{oDataModel&amp;gt;StatusSnr} sapMTextBreakWord" style="width:100%;text-align:right"&amp;gt;10&amp;lt;/span&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;Any suggestions are welcome.&lt;/P&gt;
  &lt;P&gt;Thanks in advance&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 05:47:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/set-class-dynamically-via-odata-binding/qaq-p/584105</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-04-24T05:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Set class dynamically via odata binding</title>
      <link>https://community.sap.com/t5/technology-q-a/set-class-dynamically-via-odata-binding/qaa-p/584106#M133707</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;
  &lt;P&gt;you can try setting the css property dynamically using the customData property of the control.&lt;/P&gt;
  &lt;P&gt;give it a try here is an &lt;A href="https://jsbin.com/resuta/2" target="_blank"&gt;Example&lt;/A&gt;&lt;/P&gt;
  &lt;P&gt;regards&lt;/P&gt;
  &lt;P&gt;GB&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 04:48:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/set-class-dynamically-via-odata-binding/qaa-p/584106#M133707</guid>
      <dc:creator>vaibhav_gb</dc:creator>
      <dc:date>2018-04-25T04:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Set class dynamically via odata binding</title>
      <link>https://community.sap.com/t5/technology-q-a/set-class-dynamically-via-odata-binding/qaa-p/584107#M133708</link>
      <description>&lt;P&gt;Hello GB,&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;thank you very much for this hint. I actually found a solution using customData property. In the view I use:&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;VBox class="defaultStyle"&amp;gt;
    &amp;lt;customData&amp;gt;
        &amp;lt;core:CustomData key="status-snr" value="status{oDataModel&amp;gt;StatusSnr}" writeToDom="true"&amp;gt;
    &amp;lt;customData&amp;gt;&lt;BR /&gt;... &lt;BR /&gt;&amp;lt;/VBox&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;and in the style.css I have an attribute selector:&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;.defaultStyle {
    background-color: lightgrey;
}

[data-status-snr="status10"] {
  background-color: lightgreen;
}&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;So when {oDataModel&amp;gt;StatusSnr} is evaluated to '10' the attribute data-status-snr will have value of 10 und therefore background-color is lightgreen.&lt;/P&gt;
  &lt;P&gt;Regards&lt;/P&gt;
  &lt;P&gt;Christian&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 12:49:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/set-class-dynamically-via-odata-binding/qaa-p/584107#M133708</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-04-25T12:49:21Z</dc:date>
    </item>
  </channel>
</rss>

