Line number in list?

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Sep 2, 2013
Company:

Hello;

How to add line number in Catalog List?

Sounds simple but I don't know how to do it, the only line numbers I know are in Tabular Data.

 
#2
People who like this:1Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Catalogs have built-in codes which can be of numeric type, so you simply need to display codes in the list and sort by code. This is the most reliable and useful way.

 
#3
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Sep 2, 2013
Company:

Yes, but we need something different.
Our customer needs to know how many records are there on the list, also after any filter is applied.

It can be even a simple text field with an information, we don't know how to achieve it (count of records that respects applied list filters)

 
#4
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

You need make the separate query to server for getting total number of records

Why?
So Catalog List is Dynamic List.

Dynamic List dont know total number of records.
Initially, the dynamic list displays only the first portion of the data, such as 15 records.
As the user scrolls through the list, from the server gets additional data.

Its making for displaying always actual data. Many users can add, delete catalog items and dynamic list always display all of them due to dynamic reading data.

If your task is based on the fact that the user has to operate an exact number of data selected from a database at some point in time, it is obvious that a dynamic list not suitable for this. Its need receive all of the data query and display them in a static table for example.

 
#5
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Try using idle handlers. For client operations you can call them frequently while for server calls which are slower, you can set longer period.
See the attached infobase for the example.

Code
&AtClient
Procedure OnOpen(Cancel)
   
   AttachIdleHandler("UpdateSelectedCount", 1);
   UpdateTotalCount();
   AttachIdleHandler("UpdateTotalCount", 10);
   
EndProcedure

&AtClient
Procedure UpdateSelectedCount()
   
   SelectedCount = Items.List.SelectedRows.Count();
   
EndProcedure

&AtClient
Procedure UpdateTotalCount()
   
   UpdateTotalCountServer();
   
EndProcedure

&AtServer
Procedure UpdateTotalCountServer()
   
   Query = New Query;
   Query.Text = 
      "SELECT
      |   COUNT(Goods.Ref) AS Count
      |FROM
      |   Catalog.Goods AS Goods";
   
   QueryResult = Query.Execute();
   
   SelectionDetailRecords = QueryResult.Select();
   
   While SelectionDetailRecords.Next() Do
      TotalCount = SelectionDetailRecords.Count;
   EndDo;
   
EndProcedure

Download 1Cv8.dt (14.08 KB)
 
#6
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Sep 16, 2013
Company:

Hello!

I've got similar problem to Joanna. Your solution is good to get all items count in catalog (server side) or selected rows count in catalog list (client side). My client also would like to know count of rows when any filter is applied on catalog list (clien side). What is the best way to get filter criteria applied by user at search control?

 
#7
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello,
You need to use filters of the settings composer of the dynamic list.

At the same time the user can select all records and see the count using the method above.

 
#8
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Sep 16, 2013
Company:

Could you help me with the filters of setting composer you mentioned above? I tried somthing like this:

Code
&AtClient
Procedure UpdateTotalCount()
   
   S = List.SettingsComposer;
   
   for each i in S.Settings.Filter.Items do
   ...   
   enddo;
   for each i in S.FixedSettings.Filter.Items do
   ...
   enddo;

   UpdateTotalCountServer();
EndProcedure



...but these filter items contain nothing and at the same time some filter criteria is applied by user.

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

List.SettingsComposer.Settings.Filter.Items is supposed to contain the filter values but it doesn't (I just checked it out). I need some more time to figure out why it doesn't work. As soon I get more information I'll give you an update.

 
#10
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Nov 19, 2012
Company:

Hi everyone,

In my opinion this problem is unsolvable.
1) You can use selecting rows and counting them only if there is a few thousand rows only. After each 1000 selected rows 1C platform ask you - "Selected 2000 rows. Do you want to continue?".
Are you ready to press YES 10-20-50 times? :)
Also selecting rows in thin client it is VERY slow operation.

2) As said Ivan before - this list is dynamic so platform doesn't know how much rows in this table.
For this list can be applied 3 different filters - fixed setting, user setting and fast search. You can get first two setting in code, but I do not remember how to get a user's fast search (and I believe that you cannot do it). So you cannot guarantee that this algorithm always returns to you correct result.

3) In planned version 1C 8.3.6 vendor announced new functions that will help to solve this issue.

The easiest way to count a rows with current filters - function "Output list.." in "All actions". See attachments.
Works well always and anywhere ;).

Download 1.jpg (56.5 KB)
Download 2.jpg (19.44 KB)
Download 3.jpg (27.84 KB)
 
#11
People who like this:0Yes/0No
Active user
1C:Professional
Rating: 6
Joined: May 8, 2013
Company: 1C Company

The list of filter conditions can be obtained using "List.SettingsComposer.GetSettings().Filter.Items" call. This object contains all filter conditions combined. Please note that GetSettings() method is not available on thin or WEB client, so you better use it on the server side.

 
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.