Menu icon Foundation

My Posts

No Content

My Comments

Thom Lohman commented on Martin Kearn's post about 4 years

For anyone finding that Michael's solution wasn't quite doing the job, I found it helpful to loop back through the original table rows after updating the heights and applying each value from the heights array.

Here's a revision to the setCellHeights function that worked for me.

 function setCellHeights(original, copy) {
    var tr = original.find('tr'),
        tr_copy = copy.find('tr'),
        heights = [];

    tr.each(function (index) {
      var self = $(this),
      tx = self.find('th, td');
      tx.each(function () {
        var height = $(this).outerHeight(true);
        heights[index] = heights[index] || 0;
        if (height > heights[index]) heights[index] = height;
      });

    });

    //tr_copy.each(function (index) {
      //$(this).height(heights[index]);
    //});

    tr_copy.each(function (index) {
      var self = $(this),
      tx = self.find('th, td');
      tx.each(function () {
        var height = $(this).outerHeight(true);
        heights[index] = heights[index] || 0;
        if (height > heights[index]) heights[index] = height;
      });
    });

    tr.each(function (index) {
      $(this).height(heights[index]);
    });
  }

Posts Followed


Following

    No Content

Followers

My Posts

No Content

My Comments

You commented on Martin Kearn's post about 4 years

For anyone finding that Michael's solution wasn't quite doing the job, I found it helpful to loop back through the original table rows after updating the heights and applying each value from the heights array.

Here's a revision to the setCellHeights function that worked for me.

 function setCellHeights(original, copy) {
    var tr = original.find('tr'),
        tr_copy = copy.find('tr'),
        heights = [];

    tr.each(function (index) {
      var self = $(this),
      tx = self.find('th, td');
      tx.each(function () {
        var height = $(this).outerHeight(true);
        heights[index] = heights[index] || 0;
        if (height > heights[index]) heights[index] = height;
      });

    });

    //tr_copy.each(function (index) {
      //$(this).height(heights[index]);
    //});

    tr_copy.each(function (index) {
      var self = $(this),
      tx = self.find('th, td');
      tx.each(function () {
        var height = $(this).outerHeight(true);
        heights[index] = heights[index] || 0;
        if (height > heights[index]) heights[index] = height;
      });
    });

    tr.each(function (index) {
      $(this).height(heights[index]);
    });
  }

Posts Followed

Following

  • No Content

Followers

  • No Content