Home › Forums › vLooup for SharePoint › vLookup Group Item Count next to Group
- This topic has 4 replies, 2 voices, and was last updated 4 years, 3 months ago by Alexander Bautz.
-
AuthorPosts
-
-
September 11, 2020 at 14:13 #31548
Hi Alexander,
I have a vLookup with grouping and would like to show the number of items in the group next to the group name. (just like in standard SharePoint Lists)
Is this possible to achieve ?
Thank you very much in advance.
BR,
Chris -
September 14, 2020 at 13:20 #31558
Hi Alexander,
I’ve figured out a solution myself, you don’t need to take care of this.
Thank you and BR,
Chris -
September 16, 2020 at 15:15 #31589
I’m glad you figured it out. If you could post the solution here it might be of use to others.
Alexander
-
September 18, 2020 at 07:19 #31604
Hi Alexander,
Of course, I’ve combined it with a search field that hides the not matching items and also corrects the count to show the number of items found in the corresponding group.
The picture Brosch1 shows the form ready state where the items have been counted.
The picture Brosch2 shows the filled out search box and groups with 0 count are hidden as well.The function for counting the items in the groups is shown below:
function countTotals() { var groups = $('.vLookupGroup'); $(groups).each(function(){ var count = $(this).find('tr.vLookupTableRow:not(.hidden)').length; var curcount = $(this).siblings(".vLookupGroupHeader").find('.broschcount'); if(curcount.length > 0) { curcount.text(" ("+count+")"); } else { $(this).siblings(".vLookupGroupHeader").append("<span class='broschcount'> ("+count+")</span>"); } if(count === 0) { $(this).parent().addClass('hidden'); } else { $(this).parent().removeClass("hidden"); } }); }
When the vLookup is loaded, I’m counting the totals in the groups initially:
function vLookupIsLoadedCallback(fin){ if(fin === "vLookup_Broschueren") { var groupsloaded = setInterval(function() { var groups = $('.vLookupGroup'); if(groups.length > 0) { clearInterval(groupsloaded); countTotals(); } },1000); } }
And when I’m searching for items I’m again refreshing the totals count:
function highlightMatches(elm, fin) { var sVal = jQuery(elm).val(), container = jQuery("#vLookup_" + fin + "_" + spjs.dffs.data.thisItemID).find(".vLookupTable"); container.find("tr.vLookupTableRow").removeClass("hidden"); if (sVal !== "") { container.find("tr.vLookupTableRow").each(function(i, tr) { if (jQuery(tr).text().toLowerCase().match(sVal.toLowerCase()) !== null) { //jQuery(tr).addClass("highlightSearchMatchInvLookup"); }else{ jQuery(tr).addClass("hidden"); } }); } countTotals(); }
Hope this will help someone else too 🙂
BR,
ChrisAttachments:
-
September 22, 2020 at 16:11 #31630
Thanks for sharing!
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.