<?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: sap.ui.table TreeTable Binding Problem (Scrolling) in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786830#M237916</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Glad that works &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For info, the getter and setter for properties are automaticaly created. You can access your property with &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;oRatingIndicator.getSoll()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;instead of&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;oRatingIndicator.mProperties.soll&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Fabrice&lt;/P&gt;</description>
    <pubDate>Tue, 19 Feb 2019 07:53:02 GMT</pubDate>
    <dc:creator>Fabrice</dc:creator>
    <dc:date>2019-02-19T07:53:02Z</dc:date>
    <item>
      <title>sap.ui.table TreeTable Binding Problem (Scrolling)</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaq-p/786823</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;i am currently writing a little Fiori App for intern managers to give employees a rating of their qualification. This gives HR the opportunity, to find the right training opportunities.&lt;/P&gt;
  &lt;P&gt;I am therefore using a sap.ui.table.TreeTable to visualize the hierachy of our qualification catalog, each column represents a single employee:&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/276328-qualifikationsmatrix.png" /&gt;&lt;/P&gt;
  &lt;P&gt;the number in the brackets is the must-have-value of the specific qualification.&lt;/P&gt;
  &lt;P&gt;Red = Underrated, Green: Accurate, Blue: Overrated.&lt;/P&gt;
  &lt;P&gt;Data binding:&lt;/P&gt;
  &lt;P&gt;Extended RatingIndicator to append the custom style class onAfterRendering, these style classes control the colors of the stars:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;jQuery.sap.declare("ZRatingIndicator");
sap.m.RatingIndicator.extend('ZRatingIndicator', {
	metadata: {
		properties: {
			clazz: 'string'
		}
	},
	renderer: function(oRm, oControl) {
		sap.m.RatingIndicatorRenderer.render(oRm, oControl);
	},
	onAfterRendering: function() {
		if (sap.m.RatingIndicator.prototype.onAfterRendering) {
			sap.m.RatingIndicator.prototype.onAfterRendering.apply(this);
		}


		s.onValueBasedStyleClass(this);


	}
});
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;In function onValueBasedStyleClass i fetch the styleClass:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;var styleClass;
oRatingIndicator.removeStyleClass("OVERRATED");
oRatingIndicator.removeStyleClass("UNDERRATED");
oRatingIndicator.removeStyleClass("ACCURATE");


try {
	if (soll &amp;gt; ist) {
		styleClass = "UNDERRATED";
	} else if (ist &amp;gt; soll) {
		styleClass = "OVERRATED";
	} else if (ist == soll) {
		styleClass = "ACCURATE";
	} else {
		//Nothing.
	}
	if (styleClass != undefined) {
		oRatingIndicator.addStyleClass(styleClass);
	}
} catch (e) {
	console.error(e.message);
}
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Binding:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;oNewCol = new sap.ui.table.Column({
	//[...]
	template: new sap.m.FlexBox({
		direction: "Row",
		alignItems: "Center",
		justifyContent: "Start",
		alignContent: "Center",
		items: [
			new ZRatingIndicator({
				visible: "{" + uKey + "_VISIBLE}",
				maxValue: "{" + uKey + "_MAX}",
				value: "{" + uKey + "_VALUE}",
				tooltip: "{" + uKey + "_TOOLTIP}",
				editable: "{" + uKey + "_EDITABLE}",


				customData: [
					new sap.ui.core.CustomData({
						key: "SOLL",
						value: "{" + uKey + "_MIN}"
					})
				],


				liveChange: function(oEvt) {
					//[...]
				}


			}),
			new sap.m.Label({
				text: "(" + "{" + uKey + "_MIN}" + ")",
				visible: "{" + uKey + "_VISIBLE}",
				tooltip: "Minimum",
				design: "Bold"
			}).addStyleClass("MAX_LABEL")
		]
	})
});
oTreeTable.addColumn(oNewCol);
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;CSS (e.g.):&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;.UNDERRATED &amp;gt; .sapMRISel {
    float: left;
    display: block;
    overflow: hidden;
    padding: 0;
    margin: 0;
    color: #b00;
    word-wrap: normal;
    white-space: nowrap;
}


.UNDERRATED &amp;gt; .sapMRIHov {
    float: left;
    display: none;
    overflow: hidden;
    word-wrap: normal;
    white-space: nowrap;
    color: #b00;
}
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;This works fine on first sight.&lt;/P&gt;
  &lt;P&gt;When i scroll down, still good.&lt;/P&gt;
  &lt;P&gt;When i scroll up by one mouse wheel step, the binding has some pain.&lt;/P&gt;
  &lt;P&gt;First rendering after scroll down:&lt;/P&gt;
  &lt;P&gt;1 out of 5 stars, must-have 4, --&amp;gt; Underrated --&amp;gt; Red. Binding works.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/276332-zratingindicatorunderrated.png" /&gt;&lt;/P&gt;
  &lt;P&gt;One step upstairs:&lt;/P&gt;
  &lt;P&gt;1 out of 5 stars, must-have 4 --&amp;gt; Accurate --&amp;gt; Green, WRONG!&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/276335-zratingindicatoraccurate.png" /&gt;&lt;/P&gt;
  &lt;P&gt;The whole binding paramers to the properties of RatingIndicator are fine, but the styleClass is not rendered properly.&lt;/P&gt;
  &lt;P&gt;Scrolling down again leads back to the right rendering.&lt;/P&gt;
  &lt;P&gt;Hint: problem does NOT depend on the rendering engine, but on the binding. The wrong style class is binded to the dom element:&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/276337-zratingindicatorcss.png" /&gt;&lt;/P&gt;
  &lt;P&gt;Of course i've done some data bindings through out my days as a ui5 dev, but i cant see the error this time...&lt;/P&gt;
  &lt;P&gt;If anybody has an idea, please advise!&lt;/P&gt;
  &lt;P&gt;Cheers,&lt;/P&gt;
  &lt;P&gt;Stephan&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 08:17:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaq-p/786823</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-02-15T08:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table TreeTable Binding Problem (Scrolling)</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786824#M237910</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;i think it is because the TreeTable is a sap.ui.table.Table. This Control "simulate" the rows. In the dom you only have the visible rows and when you scroll, just the bindings are changed, not the control itself. That's why when you scroll down the style class stay but the value (binding) change. Your control is no more rendered.&lt;/P&gt;&lt;P&gt;A solution could be to fetch the classes after the binding change and not in the onAfterRendering function.&lt;/P&gt;&lt;P&gt;You can, for exemple, overwrite the setValue function in your ZRatingIndicator :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;setValue : function(sValue){
   sap.m.RatingIndicator.prototype.setValue.call(this,sValue);
   s.onValueBasedStyleClass(this);   
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Fabrice&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 10:21:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786824#M237910</guid>
      <dc:creator>Fabrice</dc:creator>
      <dc:date>2019-02-15T10:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table TreeTable Binding Problem (Scrolling)</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786825#M237911</link>
      <description>&lt;P&gt;Hi Fabrice,&lt;/P&gt;&lt;P&gt;thank you for your answer.&lt;/P&gt;&lt;P&gt;This does not work for me, still the same problem.&lt;/P&gt;&lt;P&gt;I tried both, overwriting the setValue() function and add a listener on the binding's onChange event.&lt;/P&gt;&lt;P&gt;any other suggestions?&lt;/P&gt;&lt;P&gt;best regards,&lt;/P&gt;&lt;P&gt;Stephan&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 12:03:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786825#M237911</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-02-18T12:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table TreeTable Binding Problem (Scrolling)</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786826#M237912</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;do you have an error in the debugger console?&lt;/P&gt;&lt;P&gt;in debug mode, do you go in the setValue function?&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Fabrice&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 12:16:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786826#M237912</guid>
      <dc:creator>Fabrice</dc:creator>
      <dc:date>2019-02-18T12:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table TreeTable Binding Problem (Scrolling)</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786827#M237913</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;theres no error in console.&lt;/P&gt;&lt;P&gt;yep, it jumps in the setValue function, at this point of time, its too early for the customData to get binded.&lt;/P&gt;&lt;P&gt;sValue (actual value of rating) is binded, but customData.value is always null.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/275443-zratingindicatorbinding.png" /&gt;&lt;/P&gt;&lt;P&gt;Left: setValue()&lt;/P&gt;&lt;P&gt;Right: onAfterRendering()&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Stephan&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 13:20:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786827#M237913</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-02-18T13:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table TreeTable Binding Problem (Scrolling)</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786828#M237914</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;maybe you could wait for the customdata binding :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;customData:[
  newsap.ui.core.CustomData({
    key:"SOLL",
    value:"{path:" + uKey + "_MIN, events : {dataReceived : '.onDataReceivedForSOLL'} }"})
],
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and call onValueBasedStyleClass in onDataReceivedForSOLL&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;you could try a special property for your custom control and redefine the set function:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;sap.m.RatingIndicator.extend('ZRatingIndicator', {
	metadata: {
		properties: {
			clazz: 'string',
                        istAndSoll: {type : "string[]"},
		}
	},
        ...
        setIstAndSoll : function(aIstAndSoll){
            var sIst = aIstAndSoll[0];
            var sSoll = aIstAndSoll[1];
            ...
        },&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and you can bind your values without the custom data:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;new ZRatingIndicator({
				visible: "{" + uKey + "_VISIBLE}",
				maxValue: "{" + uKey + "_MAX}",
				value: "{" + uKey + "_VALUE}",
				tooltip: "{" + uKey + "_TOOLTIP}",
				editable: "{" + uKey + "_EDITABLE}",
                                istAndSoll : "{" + uKey + "_VALUE},{" + uKey + "_MIN}",
                                ... &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It is ideas, i did not test them&lt;/P&gt;&lt;P&gt;I hope it will help&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Fabrice&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 14:56:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786828#M237914</guid>
      <dc:creator>Fabrice</dc:creator>
      <dc:date>2019-02-18T14:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table TreeTable Binding Problem (Scrolling)</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786829#M237915</link>
      <description>&lt;P&gt;Hi Fabrice,&lt;/P&gt;&lt;P&gt;that's the key.&lt;/P&gt;&lt;P&gt;After switching from customData to a local property entry, the redefined onAfterRendering call always gehts the current value.&lt;/P&gt;&lt;P&gt;code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;sap.m.RatingIndicator.extend('ZRatingIndicator', {
	metadata: {
		properties: {
			clazz: 'string',
			soll: 'string'
		}
	},
	renderer: function(oRm, oControl) {
		sap.m.RatingIndicatorRenderer.render(oRm, oControl);
		
	},
	onAfterRendering: function() {
		if (sap.m.RatingIndicator.prototype.onAfterRendering) {
			sap.m.RatingIndicator.prototype.onAfterRendering.apply(this);
		}


		s.onValueBasedStyleClass(this);


	}
});
&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;new ZRatingIndicator({
	visible: "{" + uKey + "_VISIBLE}",
	maxValue: "{" + uKey + "_MAX}",
	value: "{" + uKey + "_VALUE}",
	tooltip: "{" + uKey + "_TOOLTIP}",
	editable: "{" + uKey + "_EDITABLE}",
	soll: "{" + uKey + "_MIN}",


	liveChange: function(oEvt) {
		s.onValueBasedStyleClass(oEvt.getSource(), oEvt.mParameters.value);
	}


}),&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;At onValueBaseStyleClass i dont access customData.value anymore, but custom property oRatingIndicator.mProperties.soll.&lt;/P&gt;&lt;P&gt;This property has at every point of time the right value, even after not beeing rerendered while table scrolling.&lt;/P&gt;&lt;P&gt;thank you for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 06:45:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786829#M237915</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-02-19T06:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table TreeTable Binding Problem (Scrolling)</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786830#M237916</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Glad that works &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For info, the getter and setter for properties are automaticaly created. You can access your property with &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;oRatingIndicator.getSoll()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;instead of&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;oRatingIndicator.mProperties.soll&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Fabrice&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 07:53:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-treetable-binding-problem-scrolling/qaa-p/786830#M237916</guid>
      <dc:creator>Fabrice</dc:creator>
      <dc:date>2019-02-19T07:53:02Z</dc:date>
    </item>
  </channel>
</rss>

