0

I am loading my items into table with multiple rows and multiple td. I have used partition custom filter from this link

This is my FIDDLE

myApp.filter('partition', function() {
  var cache = {};
  var filter = function(arr, size) {
    if (!arr) { return; }
    var newArr = [];

      if(size>arr.length)
          size=arr.length;

    for (var i=0; i<arr.length; i+=size) {
      newArr.push(arr.slice(i, i+size));
    }

    var arrString = JSON.stringify(arr);
    var fromCache = cache[arrString+size];
    if (JSON.stringify(fromCache) === JSON.stringify(newArr)) {
      return fromCache;
    }
    cache[arrString+size] = newArr;
    return newArr;
  };
  return filter;
});

When I give more that 4 elements its working properly. But when I provide only single product that td is occupying whole tr. I just want to have that td occupying its allocated space so that border looks good. If anybody can find workaround, Please help.

Community
  • 1
  • 1
Nitin Varpe
  • 10,450
  • 6
  • 36
  • 60

1 Answers1

1

It is not occupying the whole tr, it is because the width property of the CSS style. So, change

<table style="border-collapse: collapse; width: 50px">

to

<table style="border-collapse: collapse;">

And it will show correctly.

zs2020
  • 53,766
  • 29
  • 154
  • 219