<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Implementing Paging</title><link>https://community.telligent.com/community/11/w/developer-training/67234/implementing-paging</link><description /><dc:language>en-US</dc:language><generator>14.0.0.586 14</generator><item><title>Implementing Paging</title><link>https://community.telligent.com/community/11/w/developer-training/67234/implementing-paging</link><pubDate>Wed, 05 Aug 2020 17:35:54 GMT</pubDate><guid isPermaLink="false">9d6d876a-3f52-4c6b-b89e-9bb2a0ca562b</guid><dc:creator>Former Member</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/67234/implementing-paging#comments</comments><description>Current Revision posted to Developer Training by Former Member on 08/05/2020 17:35:54&lt;br /&gt;
&lt;p&gt;A common user interface behavior is paging through long lists of items. While there are many ways to implement this behavior, Verint Community includes built-in support for implementing paging support in a simple, consistent, and SEO friendly way.&lt;/p&gt;
&lt;p&gt;[toc]&lt;/p&gt;
&lt;h2&gt;&lt;a id="When_would_I_implement_paging" name="When_would_I_implement_paging"&gt;&lt;/a&gt;When would I implement paging?&lt;/h2&gt;
&lt;p&gt;Whenever you are implementing a list of items that is either long or unbounded, you should consider implementing paging. Paging makes loading and navigating long lists easier.&lt;/p&gt;
&lt;h2&gt;&lt;a id="How_do_I_implement_paging" name="How_do_I_implement_paging"&gt;&lt;/a&gt;How do I implement paging?&lt;/h2&gt;
&lt;p&gt;Verint Community includes configurable paging support using the &lt;code&gt;core_v2_ui.Pager()&lt;/code&gt; API. This API supports both basic (full page reloading) based paging as well as Ajax-based-paging (which only updates the paged content while leaving the remainder of the page content.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Both of the following examples assume that listing of each page of content will be done in a supplemental file named paged-list.vm:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="velocity"&gt;#set($offset = $core_v2_ui.GetCurrentPageIndex() * 10)
&amp;lt;ul&amp;gt;
#foreach($index in [1..10])
    #set($itemNumber = $index + $offset)
    &amp;lt;li&amp;gt;Item $itemNumber&amp;lt;/li&amp;gt;
#end
&amp;lt;/ul&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This sample file is not interacting with an API (to be simpler to test with) but instead reads the current page index from &lt;code&gt;core_v2_ui.GetCurrentPageIndex()&lt;/code&gt; and shows numbers 1-10 offset by the page index. If an API was being loaded, &lt;code&gt;core_v2_ui.GetCurrentPageIndex()&lt;/code&gt; still provides the current 0-based page index for which results should be loaded and displayed for this execution/rendering of paged content.&lt;/p&gt;
&lt;p&gt;Both basic and Ajax-based paging can&amp;nbsp;be used with this content listing implementation.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Basic_Paging" name="Basic_Paging"&gt;&lt;/a&gt;Basic Paging&lt;/h3&gt;
&lt;p&gt;For basic paging (where the entire page reloads), the following [[Using Velocity|Velocity]] script could be executed:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="velocity"&gt;$core_v2_widget.ExecuteFile(&amp;#39;paged-list.vm&amp;#39;)
$core_v2_ui.Pager($core_v2_ui.GetCurrentPageIndex(), 10, 100)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Because the entire page is going to be loaded whenever a new page of results is selected, we just need to execute the &lt;code&gt;paged-list.vm&lt;/code&gt; file directly to render the current list of items for the current page request. We then use &lt;code&gt;core_v2_ui.Pager()&lt;/code&gt; to render the list of pages to show based on the current page index (from &lt;code&gt;core_v2_ui.GetCurrentPageIndex()&lt;/code&gt;), number of items per page (10), and total number of items available (100).&lt;/p&gt;
&lt;h3&gt;&lt;a id="Ajax_Paging" name="Ajax_Paging"&gt;&lt;/a&gt;Ajax Paging&lt;/h3&gt;
&lt;p&gt;To enable Ajax paging where only the list of items being paged updates (and not the entire page), the following [[Using Velocity|Velocity]] script could be executed:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="velocity"&gt;$core_v2_ui.PagedContent(&amp;#39;paged-list.vm&amp;#39;)
$core_v2_ui.Pager(0, 10, 100, &amp;quot;%{ PagedContentFile=&amp;#39;paged-list.vm&amp;#39; }&amp;quot;)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Unlike the basic paging example, here the script uses &lt;code&gt;core_v2_ui.PagedContent()&lt;/code&gt; to render the paged-list.vm file. &lt;code&gt;core_v2_ui.PagedContent()&lt;/code&gt; adds a wrapping element so that the pager knows which area of the page needs to be updated when paging the list of items.&lt;/p&gt;
&lt;p&gt;Also, in this case, the &lt;code&gt;core_v2_ui.Pager()&lt;/code&gt; API will need to know the name of the file to execute (via Ajax) to get a specific page index&amp;#39;s results, so we specify &lt;code&gt;PagedContentFile&lt;/code&gt; as &lt;code&gt;paged-list.vm&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Results_of_the_Example" name="Results_of_the_Example"&gt;&lt;/a&gt;Results of the Example&lt;/h3&gt;
&lt;p&gt;Viewing&amp;nbsp;either the basic or Ajax examples above will appear the same:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " border="0" src="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/pastedimage1562611957596v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;The difference is when clicking one of the links associated with the pager: the basic example will reload the entire page whereas the Ajax pager will only update the paged content (the list of items) and the page links themselves (the remainder of the page is left unchanged which results in much faster rendering when navigating through pages of items).&lt;/p&gt;
&lt;h3&gt;&lt;a id="Additional_Options" name="Additional_Options"&gt;&lt;/a&gt;Additional Options&lt;/h3&gt;
&lt;p&gt;The pager&amp;nbsp;APIs (for both basic and Ajax paging) support many options to adjust the number/type of paging options rendered. See [[api-documentation:core_v2_ui Script API|documentation for core_v2_ui]] for more details.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: best practices, widgets&lt;/div&gt;
</description></item><item><title>Implementing Paging</title><link>https://community.telligent.com/community/11/w/developer-training/67234/implementing-paging/revision/1</link><pubDate>Mon, 08 Jul 2019 18:55:49 GMT</pubDate><guid isPermaLink="false">9d6d876a-3f52-4c6b-b89e-9bb2a0ca562b</guid><dc:creator>Ben Tiedt</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/67234/implementing-paging#comments</comments><description>Revision 1 posted to Developer Training by Ben Tiedt on 07/08/2019 18:55:49&lt;br /&gt;
&lt;p&gt;A common user interface behavior is paging through long lists of items. While there are many ways to implement this behavior, Verint Community includes built-in support for implementing paging support in a simple, consistent, and SEO friendly way.&lt;/p&gt;
&lt;p&gt;[toc]&lt;/p&gt;
&lt;h2&gt;&lt;a id="When_would_I_implement_paging" name="When_would_I_implement_paging"&gt;&lt;/a&gt;When would I implement paging?&lt;/h2&gt;
&lt;p&gt;Whenever you are implementing a list of items that is either long or unbounded, you should consider implementing paging. Paging makes loading and navigating long lists easier.&lt;/p&gt;
&lt;h2&gt;&lt;a id="How_do_I_implement_paging" name="How_do_I_implement_paging"&gt;&lt;/a&gt;How do I implement paging?&lt;/h2&gt;
&lt;p&gt;Verint Community includes configurable paging support using the &lt;code&gt;core_v2_ui.Pager()&lt;/code&gt; API. This API supports both basic (full page reloading) based paging as well as Ajax-based-paging (which only updates the paged content while leaving the remainder of the page content.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Both of the following examples assume that listing of each page of content will be done in a supplemental file named paged-list.vm:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="velocity"&gt;#set($offset = $core_v2_ui.GetCurrentPageIndex() * 10)
&amp;lt;ul&amp;gt;
#foreach($index in [1..10])
    #set($itemNumber = $index + $offset)
    &amp;lt;li&amp;gt;Item $itemNumber&amp;lt;/li&amp;gt;
#end
&amp;lt;/ul&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This sample file is not interacting with an API (to be simpler to test with) but instead reads the current page index from &lt;code&gt;core_v2_ui.GetCurrentPageIndex()&lt;/code&gt; and shows numbers 1-10 offset by the page index. If an API was being loaded, &lt;code&gt;core_v2_ui.GetCurrentPageIndex()&lt;/code&gt; still provides the current 0-based page index for which results should be loaded and displayed for this execution/rendering of paged content.&lt;/p&gt;
&lt;p&gt;Both basic and Ajax-based paging can&amp;nbsp;be used with this content listing implementation.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Basic_Paging" name="Basic_Paging"&gt;&lt;/a&gt;Basic Paging&lt;/h3&gt;
&lt;p&gt;For basic paging (where the entire page reloads), the following [[Using Velocity|Velocity]] script could be executed:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="velocity"&gt;$core_v2_widget.ExecuteFile(&amp;#39;paged-list.vm&amp;#39;)
$core_v2_ui.Pager($core_v2_ui.GetCurrentPageIndex(), 10, 100)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Because the entire page is going to be loaded whenever a new page of results is selected, we just need to execute the &lt;code&gt;paged-list.vm&lt;/code&gt; file directly to render the current list of items for the current page request. We then use &lt;code&gt;core_v2_ui.Pager()&lt;/code&gt; to render the list of pages to show based on the current page index (from &lt;code&gt;core_v2_ui.GetCurrentPageIndex()&lt;/code&gt;), number of items per page (10), and total number of items available (100).&lt;/p&gt;
&lt;h3&gt;&lt;a id="Ajax_Paging" name="Ajax_Paging"&gt;&lt;/a&gt;Ajax Paging&lt;/h3&gt;
&lt;p&gt;To enable Ajax paging where only the list of items being paged updates (and not the entire page), the following [[Using Velocity|Velocity]] script could be executed:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="velocity"&gt;$core_v2_ui.PagedContent(&amp;#39;paged-list.vm&amp;#39;)
$core_v2_ui.Pager(0, 10, 100, &amp;quot;%{ PagedContentFile=&amp;#39;paged-list.vm&amp;#39; }&amp;quot;)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Unlike the basic paging example, here the script uses &lt;code&gt;core_v2_ui.PagedContent()&lt;/code&gt; to render the paged-list.vm file. &lt;code&gt;core_v2_ui.PagedContent()&lt;/code&gt; adds a wrapping element so that the pager knows which area of the page needs to be updated when paging the list of items.&lt;/p&gt;
&lt;p&gt;Also, in this case, the &lt;code&gt;core_v2_ui.Pager()&lt;/code&gt; API will need to know the name of the file to execute (via Ajax) to get a specific page index&amp;#39;s results, so we specify &lt;code&gt;PagedContentFile&lt;/code&gt; as &lt;code&gt;paged-list.vm&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Results_of_the_Example" name="Results_of_the_Example"&gt;&lt;/a&gt;Results of the Example&lt;/h3&gt;
&lt;p&gt;Viewing&amp;nbsp;either the basic or Ajax examples above will appear the same:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " border="0" src="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/pastedimage1562611957596v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;The difference is when clicking one of the links associated with the pager: the basic example will reload the entire page whereas the Ajax pager will only update the paged content (the list of items) and the page links themselves (the remainder of the page is left unchanged which results in much faster rendering when navigating through pages of items).&lt;/p&gt;
&lt;h3&gt;&lt;a id="Additional_Options" name="Additional_Options"&gt;&lt;/a&gt;Additional Options&lt;/h3&gt;
&lt;p&gt;The pager&amp;nbsp;APIs (for both basic and Ajax paging) support many options to adjust the number/type of paging options rendered. See [[api-documentation:core_v2_ui Script API|documentation for core_v2_ui]] for more details.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item></channel></rss>