Question

Total Row Count

  • 22 January 2019
  • 7 replies
  • 45 views

The count function for the list view only will count up to the filtered number, but is there a way to get all of the rows on all pages, not just the first x amount? ListCount(x) will only get the number of the visible list items, but I need all items.


7 replies

Badge +1

Hi Alexandre,

 

I don't think this feature is currently available in K2.

 

As an alternaltive, have a look at Raymond's solution in the below article for a possible workaround:
http://community.k2.com/t5/K2-Blackpearl-Forum-Posts/Count-number-of-Rows-in-View/td-p/60939

 

Kind regards,
Sello

Dear Sello,

 

Unfortunately, when I try to do the for each and transfer method it will stop at the number of rows presented (in my case the 10 I have the filter set to). To get what I wanted I had to create a hidden tab that acted as an unfiltered data dump.

 

Kind Regards,

Alexandre

Userlevel 4
Badge +8

How are you populating this list? Do you have the flexibility to return the total row count from the data source (web service or stored proc)? You can then save that off into a hidden data field and reference it as needed or display it in the footer row. Not a great solution as it involves returning data that the list should know about, but it is one idea.

Hi

 

Another possible way is to configure a varible in the workflow to get the total number of records and then have the value of that varible be displayed in the desired place on the form.

 

For aditional help: 

Varibles in a workflow - https://help.k2.com/onlinehelp/k2five/userguide/5.2/default.htm#K2-Workflow-Designer/Use/Toolbox/Basic/SetVariables/Set-Variables.htm 

 

 

Regards Jacques.

This is using a simple K2 smartbox. Unfortunately, there is no link to any webservices or other data provider. 

 

Thank you for the idea though!

Dear  Jacques,

 

I am just using this form as a data presentation tool, so it has no workflow connection.

 

Thank you for the idea though!

 

Kind Regards,

Alexandre

Badge +7

Hi Alexandremirand


 


Unfortuanitly there is no out of the box way to intercept the pagination exexution as it happen in line with the views initailization from the backend with no visibility to the user or view developer. The view will only count the amout of record is can find on the currently visible page when pagination is enabled on a list view.


 


There are however some alternative that can help get the total count onto the same view that is beign paginated however some of them could cause some loading delay, see the altenatives I could think of below:


 


Option 1


Obtain the total count with another smartobject call that would display the data eiter off-view in another view and pass the count to the current view.


 


Option 2


Obtain the total count with another smartobject call that would populate a sepearte control in the same view.  


Keep in mind that both option 1 and 2 would take additional load time which can cause loading delays on the view especially when there are thousands of records that need to load in.


 


Option 3 (best option in my opinion)


Another alternative which might be the best one to use to maintain performance and avoid double time on the view loading would be to do the count from the database side via an stored procedure and then create a smartobject from that stored procedure via the service instace used to connect to K2. You can then call the SmartObject on the list views initialize rule to populate a data label with the full count.I ran a quick test with this on a K2 5.2 installation and it seems to deliver the best  out of the box results preformance wise.


 


To see the results of the test and steps preformed, expand the following spoiler tag:


 


Step 1: Created a SmartObject and added 10 rows of data to it.
Step 2: Then enabled pagination on 5 rows per page.

Step 3: Created a the following stored procedure in SQL

Keep in mind that you would need to replace the "#####" section in the stored procedure with the name of the relevant table.


CREATE PROCEDURE ReturnCount 
AS
BEGIN
SELECT COUNT(*) FROM [K2].[SmartBoxData].[#####]
END
GO

--The below is used to execute the stored procedure
Execute ReturnNameCount;

Step 4: Created a SmartObject from the stored procedure via the SQL service instance
Step 5: Added a standard column count.
Step 6: Executed this SmartObject on the editable list views initalize method and returned the output to a data label called total count.

Refernecing Community post:https://community.k2.com/t5/K2-Blackpearl-Forum-Posts/Count-number-of-Rows-in-View/m-p/106819#M35079


 


Should you feel that this post is of use and or an accurate solution to the raised question, I kindly encourage you to mark it as such using the 'Mark as Solution', 'Kudo' andor ‘Me Too’ options.


 


Kind Regards


Raymond


 

Reply