Skip to main content

7 replies

12-Amethyst
August 8, 2024

Hi, 

I have a SQL service which is giving an infotable output and I have bind this infotable to a grid and now I want to paginate this grid data so please recommend how can I do this 

Thing Name: TestThing
DataShape: TestDS
service: SQLData (this is to fetch data from postgres )

 

now I want to implement pagination to the grid data so please recommend/implement the solution

 

Regards,

Lav

Translate
Catalina
Community Moderator
August 8, 2024

Hello,

 

It was brought to our attention that these were duplicate questions. We have merged the two, so all the relevant information is in one place.

 

Thank you for your participation in the Community!

 

Best regards,

Translate
Catalina | PTC Community Moderator
Rocko
19-Tanzanite
August 8, 2024
12-Amethyst
August 12, 2024

Hi @Rocko 
I tried looking in to this but still not sure how to create a service which will fulfill my requirement
I have a SQL service:

select * from Product_Table;

LY_10691079_0-1723452473025.png

 

Can you give me a basic Idea that how can I include this pageNumer and pageSize to this service so that it can fetch the actual 
results in the mashup that will be appreciated

 

Thanks,

Lav. 

 

 

Translate
Rocko
19-Tanzanite
August 12, 2024

In general you have two options. Getting the all of the data from the db into an infotable and show it only pagewise to the users. This is shown here: https://support.ptc.com/help/thingworx/platform/r9.5/en/#page/ThingWorx/Help/Mashup_Builder/Widgets/CreatingAPaginationService.html#wwID0EN3MDB

You would have no more DB queries when the user browses through the pages as TWX already got all the data. The disadvantage is that you pull all data ahead, even if it might never get rendered.

The alternative is to put the paging information into the query, using LIMIT and OFFSET keywords, e.g.

SELECT vehicle_number, dept_id, type FROM employee
ORDER BY employee.id DESC LIMIT 20 OFFSET 20;

which will get you entries 20 to 40. In that case you will have to add [[]] placeholders into the query (see https://www.ptc.com/en/support/article/CS413368) The advantage is that this way you only pull the data that is being displayed, the disadvantage is that when the table changes between the paging queries it might show updated data. Plus you will have to add some logic to determine how many rows there are in total, so the pagination widget knows how many pages to display.

Translate