vLookup Group Item Count next to Group

Forums vLooup for SharePoint vLookup Group Item Count next to Group

Viewing 4 reply threads
  • Author
    Posts
    • #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

    • #31558

      Hi Alexander,

      I’ve figured out a solution myself, you don’t need to take care of this.

      Thank you and BR,
      Chris

    • #31589
      Alexander Bautz
      Keymaster

      I’m glad you figured it out. If you could post the solution here it might be of use to others.

      Alexander

    • #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,
      Chris

    • #31630
      Alexander Bautz
      Keymaster

      Thanks for sharing!

      Alexander

Viewing 4 reply threads
  • You must be logged in to reply to this topic.