Splitting query output

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

Hello, I am trying to use 1C:Enterprise as a backend for my project. I need to present some search results in pages.

How to split the search results into pages? (like page 1, page 2, page 3...)

When the user searches for products on my project website, I want results to be split into several pages showing around 20 results per page. The search results are the outcome of database query.

For example: If the user searches for Samsung mobiles so my query will be:

SEL ECT * FR OM PRODUCTS WHERE BRAND='SAMSUNG';

Suppose the above query returns 55 results, how to show them into pages (1,2 and 3)?

How could I use internal caching? Are there any best practices? Should I store temporarily the result during user session? Could this be done automatically?

p.s I do not want to send all results to the client. It could take some time (could be 200 pages)

 
#2
People who like this:0Yes/0No
Interested
Rating: 16
Joined: Dec 4, 2017
Company:

Dear Alexey,

We are preparing an answer for you and will return back soon with it.

Best regards,
Vladimir Gurov

1C Company support team
 
#3
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

Vladimir, I have tried to perform it via OData, but if I connect to the same infobase it hangs.
I can not connect to the OData interface directly, because it seems like it does not have rights restriction I need.

 
#4
People who like this:0Yes/0No
Active user
1C:Professional
Rating: 6
Joined: May 8, 2013
Company: 1C Company

Hello Alexey,

There is nothing ready-to-go in the platform for this type of tasks, but you have many different options for implementing this functionality yourself.

The most natural one is to show the list in a specific order and download next/previous page adding a condition > or < for the order key fields.

Say, you have attribute KEY_FIELD in the table and show the list in its order by 20 items per page. You first-page query will look like this:

SELECT TOP 20 * FROM PRODUCTS WHERE BRAND='SAMSUNG' ORDER BY KEY_FIELD

After you received this page you should save the last KEY_FIELD value and use it as a condition when you download the next page:

SELECT TOP 20 * FROM PRODUCTS WHERE BRAND='SAMSUNG' AND KEY_FIELD > &LAST_KEY_FIELD ORDER BY KEY_FIELD

You can choose where to implement this - in your app or on the 1C server side.

If you're implementing it in your app, you definitely don't want this kind of functionality to work in a browser. So you will need a site backend (some NodeJS application or whatever) to handle this pages loading and switching. This NodeJS code should request data through REST API.

You also could implement this page-switching logic on the 1C server side (using 1C script language). Then you can publish your own API as a SOAP service (1C web service) and request it from browser JS directly if necessary.

Edited: Konstantin Rupasov - Dec 06, 2017 06:37 PM
 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.