GD Bloggers

This is the blog site for Microsoft Global Delivery Communities focused in sharing the technical knowledge about devices, apps and cloud.
Follow Us On Twitter! Subscribe To Our Blog! Contact Us

InfoPath 2010 Paging (without coding)

InfoPath 2010 Paging (without coding)

  • Comments 13
  • Likes

Introduction

In this post I will try to show you how to implement a simple paging mechanism using InfoPath 2010. This approach is useful if you are considering a quick & fast solution to handle InfoPath Repeating Tables (or sections) that returns 100s of items without writing code behind and by following few simple steps.

 

 

How to do it:

In this scenario I already have an InfoPath Form that has a sample Repeating Table that returns more than 300 items. I would like to configure it to show a 100 item on each page, below are the steps:

1- Add a new field on you Main Data Source as following:

 

 

2- Add 2 new buttons on the form to handle Previous & Next Pages:

3-  In the InfoPath Repeating Table (or Section) add a new column and inset a new Calculated Value Control from the Controls Ribbon. This Calculated Value will hold the Row Number of the data that you retrieve:

4- Open the newly added Calculated Value Property and update your Data Source using the Position() XPath:

5- Create a Rule for the Previous Page Button on Click as following:

Rule Name: Previous Rule

Condition: PageNumber != 1

Action: Set Fields Value of PageNumber = PageNumber - 1

 

6- Create a Rule for the Next Page Button on Click as following:

 

Rule Name: Next Rule

Condition: PageNumber <= Count(ID) / 100

Action: Set Fields Value of PageNumber = PageNumber + 1

Note:

  • Whenever you see the number 100 it represents the page size.
  • you can select any fields with the Count() function, in this scenario I used ID field.

 

7- Now the Tricky Part ... you need to create 2 new Formatting Rules on the Repeating Table as following:

 

Rule Name: Hide Rule 1

Condition (Expression): position() >= 100 * xdXDocument:get-DOM()/my:myFields/my:PageNumber

Check on: Hide this Control

 

 

Rule Name: Hide Rule 2

Condition (Expression): position() < 100 * (xdXDocument:get-DOM()/my:myFields/my:PageNumber - 1)

Check on: Hide this Control

 

 

 

And that all folks ... Run your form and start Paging :)

 

 

Comments
  • I'm getting Position() XPath not supported

  • Can you check the following:

    - Write it using lower case such as position()

    - Version of InfoPath?

  • when you create the calculated field click OK without inserting position(). Next right click on the calculated field --> calculate value properties, then type position() in XPath field and click OK.

  • Hi, Thanks for your post i used above way to apply paging for repeated tale in my info path form, i have a conditional formatting for the repeated table for filtering purpose, the problem is when i get a result after filtering i have to navigate across pager to reach the result "empty pages result".

    ex: suggest i have list items "P1,P2,P3,P4,P5"

    apply paging  "Page size = 3" :

     page1 : "P1,P2,P3"

     Page2 : "P4,P5"

    when apply some filter that return only "P5", then i have to navigate to "page 2" to see the result "P5".

    which mean repeated table paging is still counting for original data, not the result that returned after conditional formatting applied.

    result:

    Page 1 : ""

    Page 2: "P5"

    expected result:

    Page 1 : "P5"

  • Please advice ASAP , Thanks Again

  • Hi Laith,

    The above approach is suitable for simple scenarios as it doesn't affect the number of items bound to the Repeating Table. What you are looking for can be accomplished using code behind to filter results first then implement your custom paging mechanism before binding to the Info Path Repeating Table.

  • It should be > for the first Hide Rule 1 condition and <= for the Hide Rule 2 condition :) Thanks for the idea

  • We are currently using SharePoint 2010 and Office 2010 for our Intranet. We have an InfoPath from a co-hospital and would like to use the same form. We changed the titles and some rules on the form and now we are starting to the following problem. “A view is set up with maybe 10-25 items to view. The next day only the top 5 are still chosen. This has happened each day since Monday after we made some changes to the form.”

  • how do i set pagging size mean how to set As i wanted to show only 10 or 20 data

  • The position() formula won't work on browser enabled forms. Instead of "position()" you can use "count(preceding-sibling::*) + 1". Hope that this helps!

  • thank you

  • I set up all as above - previewed form, page number will change but buttons do not move to the next page? any help?

  • For infopath 2013:
    my condition for repeating table:
    count(preceding-sibling::*) >= xdXDocument:get-DOM()/my:myFields/my:paging/my:pageNumber * xdXDocument:get-DOM()/my:myFields/my:paging/my:rowPerPage

    OR

    count(preceding-sibling::*) + 1 <= xdXDocument:get-DOM()/my:myFields/my:paging/my:pageNumber * xdXDocument:get-DOM()/my:myFields/my:paging/my:rowPerPage - xdXDocument:get-DOM()/my:myFields/my:paging/my:rowPerPage

    it works.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment