<?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: Bind Paginator to model? in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/bind-paginator-to-model/qaa-p/9120331#M3236104</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi DJ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the inherited "bind" methods are the generic ones that can be used to bind &lt;STRONG&gt;any &lt;/STRONG&gt;property or aggregation of &lt;STRONG&gt;any &lt;/STRONG&gt;Control. &lt;/P&gt;&lt;P&gt;(there may be exceptions, where a property documentation says that setting the value is only possible at certain times or so, but this is at least the general rule)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the "numberOfPages" is a number property, so you can only bind it to a number which is present in the model. So either the service that provides your blog entries needs to also provide the count or you need to do the counting yourself.&lt;/P&gt;&lt;P&gt;When you really want to use the binding (so the count and the paginator would automatically adapt if a new blog post is added to the Model) you can use a formatter function in the binding:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; oPaginator.bindProperty("numberOfPages", "/entry", function(value) {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // binding goes against the array, so "value" is the whole array now... &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // this formatter returns the array length, which is the blog post count&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (value){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return value.length;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; });&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually I'm not 100% sure how such a property binding agains an array reacts on data changes and whether this usage is intended and fully supported, but at least it does work. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See a running example here (only runs in Chrome/Firefox, not in IE, because UI5 is loaded cross-domain):&lt;/P&gt;&lt;P&gt;&lt;A href="http://jsbin.com/aku_paginator_bound/2/edit"&gt;http://jsbin.com/aku_paginator_bound/2/edit&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers - and a Happy New Year!&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Dec 2012 09:31:21 GMT</pubDate>
    <dc:creator>AndreasKunz</dc:creator>
    <dc:date>2012-12-28T09:31:21Z</dc:date>
    <item>
      <title>Bind Paginator to model?</title>
      <link>https://community.sap.com/t5/technology-q-a/bind-paginator-to-model/qaq-p/9120330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was wondering if anyone had tried binding a &lt;A href="https://sapui5.netweaver.ondemand.com/sdk/#docs/api/symbols/sap.ui.commons.Paginator.html"&gt;Paginator&lt;/A&gt; to a model, to have the numberOfPages automatically set to the number of entries in the model's row set. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As an example, I'd developed a simple Panel/HTML representation of my weblog posts (in preparation for "&lt;A href="http://www.youtube.com/watch?v=wZUXz5f1CHI"&gt;Re-presenting my site in SAPUI5&lt;/A&gt;") and then added a Paginator at the top to page through the posts. It looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/165840" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In order to work out what value to set the numberOfPages to, I ended up using jQuery to parse the source XML that the Model had consumed, and count the number of 'entry' elements. You can see the code here: &lt;A href="https://github.com/qmacro/sapui5bin/blob/master/snippets/model_to_html.html#L31" title="https://github.com/qmacro/sapui5bin/blob/master/snippets/model_to_html.html#L31"&gt;https://github.com/qmacro/sapui5bin/blob/master/snippets/model_to_html.html#L31&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I noticed in the docu that the Paginator inherits a number of bind methods from sap.ui.core.Element, and was curious to see whether binding a Paginator could auto-set the numberOfPages according to the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone tried this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Dec 2012 22:28:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/bind-paginator-to-model/qaq-p/9120330</guid>
      <dc:creator>qmacro</dc:creator>
      <dc:date>2012-12-13T22:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Bind Paginator to model?</title>
      <link>https://community.sap.com/t5/technology-q-a/bind-paginator-to-model/qaa-p/9120331#M3236104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi DJ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the inherited "bind" methods are the generic ones that can be used to bind &lt;STRONG&gt;any &lt;/STRONG&gt;property or aggregation of &lt;STRONG&gt;any &lt;/STRONG&gt;Control. &lt;/P&gt;&lt;P&gt;(there may be exceptions, where a property documentation says that setting the value is only possible at certain times or so, but this is at least the general rule)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the "numberOfPages" is a number property, so you can only bind it to a number which is present in the model. So either the service that provides your blog entries needs to also provide the count or you need to do the counting yourself.&lt;/P&gt;&lt;P&gt;When you really want to use the binding (so the count and the paginator would automatically adapt if a new blog post is added to the Model) you can use a formatter function in the binding:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; oPaginator.bindProperty("numberOfPages", "/entry", function(value) {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // binding goes against the array, so "value" is the whole array now... &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // this formatter returns the array length, which is the blog post count&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (value){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return value.length;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; });&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually I'm not 100% sure how such a property binding agains an array reacts on data changes and whether this usage is intended and fully supported, but at least it does work. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See a running example here (only runs in Chrome/Firefox, not in IE, because UI5 is loaded cross-domain):&lt;/P&gt;&lt;P&gt;&lt;A href="http://jsbin.com/aku_paginator_bound/2/edit"&gt;http://jsbin.com/aku_paginator_bound/2/edit&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers - and a Happy New Year!&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Dec 2012 09:31:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/bind-paginator-to-model/qaa-p/9120331#M3236104</guid>
      <dc:creator>AndreasKunz</dc:creator>
      <dc:date>2012-12-28T09:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Bind Paginator to model?</title>
      <link>https://community.sap.com/t5/technology-q-a/bind-paginator-to-model/qaa-p/9120332#M3236105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Andreas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for answering, and what a lovely answer it was too. Using property formatters to bridge the gap between control properties and values that don't actually exist explicitly in the model is a great solution. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also learned something from the last bit of your code example: that you can use placeAt() multiple times pointing at the same element id, and the controls will simply be appended.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;oPanel.placeAt("content");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;oPaginator.placeAt("content");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers, and all the best for 2013!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Dec 2012 12:03:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/bind-paginator-to-model/qaa-p/9120332#M3236105</guid>
      <dc:creator>qmacro</dc:creator>
      <dc:date>2012-12-28T12:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Bind Paginator to model?</title>
      <link>https://community.sap.com/t5/technology-q-a/bind-paginator-to-model/qaa-p/9120333#M3236106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andreas and DJ Adams,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Great post this one! I am doing some stuff with SAPUI5 and SAP MII and I am just wondering if you guys have any example using XML Model and a table using a paginator with the &lt;SPAN style="color: #333333; font-size: 12px; background-color: #ffffff;"&gt;navigationMode: sap.ui.table.NavigationMode.Paginator.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px; background-color: #ffffff;"&gt;Any clues will be much appreciated! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px; background-color: #ffffff;"&gt;Thanks guys!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px; background-color: #ffffff;"&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px; background-color: #ffffff;"&gt;Bruno&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Jun 2013 15:14:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/bind-paginator-to-model/qaa-p/9120333#M3236106</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-06-05T15:14:28Z</dc:date>
    </item>
  </channel>
</rss>

