2

i am trying to remove of table if all values of that table are same i am using below table You can view this in JSFiddle MY Name00:566£88.877 My Name00:566£88.87167

        <tr class="Awaitingdispatch" align="center" valign="middle">
        <td>XYZ </td><td>02.52</td><td>6</td><td>£150.25</td><td class="hideGridColumn">167</td>
    </tr>
        <tr class="Awaitingdispatch" align="center" valign="middle">
        <td>My Name</td><td>02:56</td><td>167</td><td>£150.25</td><td class="hideGridColumn">167</td>
    </tr>
</table>

css: .gridview-container table { font-size:12px; }

    .gridview-container tr:first-child td
    {
        font-weight:bold;
        text-align:center;
        }
    .hideGridColumn
    {
        display:none;
    }

    .dispatch 
    {background : lightgreen;
        }
.PRESS 
    {background :#FF9933;
        }
        .Awaitingdispatch
         {background :yellow;
        }

DEMO On JSFIddle

Here i want to remove row if all cells are equal Note : i want ignore hidden cells

1
  • You forgot to include jquery library in jsfiddle.. I have updated it.. jsfiddle.net/spdc9oyv/8 Commented Feb 4, 2015 at 13:21

1 Answer 1

2

The code below deletes all rows with similar values:

function removeDuplicateRows($table){
    function getVisibleRowText($row){
        return $row.find('td:visible').text().toLowerCase();
    }

    $table.find('tr').each(function(index, row){
        var $row = $(row);
        $row.nextAll('tr').each(function(index, next){
            var $next = $(next);
            if(getVisibleRowText($next) == getVisibleRowText($row))
                $next.remove();
        })
    });
}

removeDuplicateRows($('table'));

Fiddle

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.