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.
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.
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.
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?
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.
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.
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 .
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.